[英]Programmatically configure Eclipse Installed JREs
I want to configure my Eclipse environment to use the JDK instead of the standard JRE. 我想配置我的Eclipse环境以使用JDK而不是标准JRE。 I'm doing this because I use m2eclipse, which requires tools.jar from the JDK to run.
我这样做是因为我使用m2eclipse,这需要JDK中的tools.jar来运行。
I'm running Eclipse 3.5.1 on Windows 7 32-bit with JDK 1.6.0_16. 我正在使用JDK 1.6.0_16在Windows 7 32位上运行Eclipse 3.5.1。
On my system, I have the JDK installed to "C:\\Program Files\\Java\\jdk" (symlink to the latest install). 在我的系统上,我将JDK安装到“C:\\ Program Files \\ Java \\ jdk”(最新安装的符号链接)。
I add the -vm option to eclipse.ini to point to the JDK 我将-vm选项添加到eclipse.ini以指向JDK
-vm
C:/Program Files/Java/jdk/bin
I've confirmed that eclipse is in fact starting with the desired JVM. 我已经确认eclipse实际上是从所需的JVM开始的。 In the configuration details
在配置细节中
eclipse.vm=c:/Program Files/Java/jdk/bin\..\jre\bin\client\jvm.dll
Additionally, in my environment, 另外,在我的环境中,
JAVA_HOME=c:\Program Files\Java\jdk
However, in Window | 但是,在Window |中 Preferences |
偏好| Java |
Java | Installed JREs, the only JRE listed is the one in "C:\\Program Files\\Java\\jre6".
安装的JRE,列出的唯一JRE是“C:\\ Program Files \\ Java \\ jre6”中的JRE。 This JRE ends up being the one under which Maven is run, and so my maven builds fail.
这个JRE最终成为运行Maven的那个,所以我的maven构建失败了。
I know I can manually change the Installed JRE to point to the JDK, and this is what I've done in the past. 我知道我可以手动将Installed JRE更改为指向JDK,这就是我过去所做的。 However, I'd like to find a way to script this change so that I can automate the installation of a dev environment.
但是,我想找到一种方法来编写此更改的脚本,以便我可以自动安装开发环境。
Where is this setting stored? 这个设置存储在哪里? What is the best way to automatically configure Eclipse to use the JDK as the only Installed JRE?
自动配置Eclipse以将JDK用作唯一安装的JRE的最佳方法是什么?
The setting is stored in 该设置存储在
<workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.launching.prefs
I would recommend setting your JDK manually in Preferences / Java / Installed JRE, as well as Preferences / Java / Installed JRE / Execution Environment. 我建议在Preferences / Java / Installed JRE以及Preferences / Java / Installed JRE / Execution Environment中手动设置JDK。
Then, whenever you need an eclipse with that exact configuration, just copy over this file with your preset config file, and launch that eclipse. 然后,每当您需要具有该确切配置的eclipse时,只需使用您的预设配置文件复制该文件,然后启动该eclipse。
Extract from that config file: 从该配置文件中提取:
org.eclipse.jdt.launching.PREF_DEFAULT_ENVIRONMENTS_XML=
<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>
<defaultEnvironments>
<defaultEnvironment environmentId\="JavaSE-1.6"
vmId\="57,org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType13,1255369536255"/>
</defaultEnvironments>
eclipse.preferences.version=1
org.eclipse.jdt.launching.PREF_VM_XML=
<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>
<vmSettings defaultVM\="57,org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType13,1255369536255">
<vmType id\="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType">
<vm id\="1255369536255"
javadocURL\="http\://java.sun.com/javase/6/docs/api/"
name\="jdk1.6.0_16" path\="C\:\\Prog\\Java\\jdk1.6.0_16">
<libraryLocations>
<libraryLocation jreJar\="C\:/Prog/Java/jdk1.6.0_16/jre/lib/resources.jar"
jreJavadoc\="http\://java.sun.com/javase/6/docs/api/"
jreSrc\="C\:/Prog/Java/jdk1.6.0_16/src.zip"
pkgRoot\=""/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.