简体   繁体   English

以编程方式配置Eclipse Installed JRE

[英]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.

相关问题 Eclipse不再找到已安装的JRE - Eclipse doesn't find the installed JREs anymore Eclipse如何区分“已安装的JRE”的JDK和JRE? - How does Eclipse differentiate JDK and JRE for the “Installed JREs”? 在 Eclipse 中使用 JRE 与 JDK(已安装的 JRE?!),哪个更好? - Using JRE vs JDK (installed JREs?!) in Eclipse, what´s better? Eclipse:是否有一种简单的方法来协调整个团队中的“已安装JRE”? - Eclipse: Is there an easy way to coordinate “Installed JREs” across a team? 是否可以使用相对路径和Eclipse变量将JRE添加到Eclipse中的Installed JRE中? - Is it possible to add a JRE to Installed JREs in Eclipse using relative path and Eclipse variables? 已安装JDK和JRE,但是带有ADT的Eclipse Juno在Mac OS Mavericks上找不到它们 - JDK and JREs installed, but Eclipse Juno with ADT can't find them on Mac OS Mavericks 对于多个Java版本,避免在Eclipse中“没有在严格兼容的工作空间中安装JRE”警告 - Avoid the “no JREs installed in the workspace that are strictly compatible” warning in Eclipse for multiple Java versions Eclipse插件开发人员-没有安装的JRE满足此执行环境:“ JavaSE-1.7”。 发射中止 - Eclipse plugin dev - No installed JREs satisfy this Execution Environment: “JavaSE-1.7”. Launch aborted Eclipse 中安装的 JRE 与“标准 VM”和“MacOS X VM”有什么区别? - What's the difference from "Standard VM" and "MacOS X VM" in installed JREs in Eclipse? ADT在Mac上找不到已安装的JRE - ADT can't find installed JREs on Mac
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM