您的位置:首页 > 编程语言 > Java开发

[Java]_[绿色版的jdk压缩包如何设置JRE环境]

2012-11-28 23:22 555 查看
1.运行一些jar时,或一些exe时,出现提示:This application requires Java Runtime Environment 1.5.0 .这时候可以去下载JDK重新安装就会有JRE可选安装,之后jar或exe就可以运行了,但是jdk本身就是绿色软件,之前是通过设置JAVA_HOME环境变量来使用jdk的,不想使用安装版装上不必要的东西。

2.或者下载链接里已经很难找到对应的Jdk版本了。

3.这时候可以通过添加一些注册表使用jdk里的jre。

参考了一些文章,可惜google老是找不到原来的网址,贴上部分原文.

Not as a command, but this information is in the registry:

Open the keyHKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment
Read the CurrentVersion REG_SZ
Open the subkey under Java Runtime Environment named with the CurrentVersion value
Read the JavaHome REG_SZ to get the path

For example on my workstation i have

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment
CurrentVersion = "1.6"
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.5
JavaHome = "C:\Program Files\Java\jre1.5.0_20"
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6
JavaHome = "C:\Program Files\Java\jre6"

So my current JRE is in C:\Program Files\Java\jre6


所以制作一个注册表文件即可,使用记事本,新建一个文档,贴上以下内容,保存为.reg文件,之后运行即可注册JRE环境。再次运行程序就不会出现提示了。

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft]

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment]
"CurrentVersion" = "1.6"

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6]
"JavaHome" = "C:\\software\\Java\\jdk1.6.15\\jre"


eclipse配置启动的Jdk

-vm
C:\software\Java\jdk1.6.15\bin\javaw.exe
-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-product
org.eclipse.epp.package.cpp.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
128M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
128M
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40M
-Xmx512M
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: