以编程方式配置Eclipse安装的JRE [英] Programmatically configure Eclipse Installed JREs

查看:135
本文介绍了以编程方式配置Eclipse安装的JRE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想配置我的Eclipse环境来使用JDK而不是标准的JRE。我正在这样做,因为我使用m2eclipse,这需要从JDK的tools.jar运行。

I want to configure my Eclipse environment to use the JDK instead of the standard JRE. I'm doing this because I use m2eclipse, which requires tools.jar from the JDK to run.

我在Windows 7 32位运行Eclipse 3.5.1使用JDK 1.6.0_16。

I'm running Eclipse 3.5.1 on Windows 7 32-bit with JDK 1.6.0_16.

在我的系统上,我将JDK安装到C:\Program Files\Java\jdk(符号链接到最新安装)。

On my system, I have the JDK installed to "C:\Program Files\Java\jdk" (symlink to the latest install).

我将eclipse.ini中的-vm选项添加到指向JDK

I add the -vm option to eclipse.ini to point to the JDK

-vm
C:/Program Files/Java/jdk/bin

我已经确认eclipse实际上是从所需的JVM开始的。在配置详细信息中

I've confirmed that eclipse is in fact starting with the desired JVM. In the configuration details

eclipse.vm=c:/Program Files/Java/jdk/bin\..\jre\bin\client\jvm.dll

此外,在我的环境中,

JAVA_HOME=c:\Program Files\Java\jdk

但是,在Window |中偏好| Java |安装的JRE,列出的唯一JRE是C:\Program Files\Java\jre6中的JRE。这个JRE最终是运行Maven的,所以我的maven构建失败。

However, in Window | Preferences | Java | Installed JREs, the only JRE listed is the one in "C:\Program Files\Java\jre6". This JRE ends up being the one under which Maven is run, and so my maven builds fail.

我知道我可以手动更改已安装的JRE来指向JDK,这就是我以前做过的事情。但是,我想找到一种方法来编写此更改,以便我可以自动安装开发环境。

I know I can manually change the Installed JRE to point to the JDK, and this is what I've done in the past. However, I'd like to find a way to script this change so that I can automate the installation of a dev environment.

存储此设置在哪里?自动配置Eclipse以将JDK用作唯一安装的JRE的最佳方式是什么?

Where is this setting stored? What is the best way to automatically configure Eclipse to use the JDK as the only Installed JRE?

推荐答案

设置存储在

<workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.launching.prefs

我建议您在首选项/ Java /安装的JRE,以及首选项/ Java /安装的JRE /执行环境。

I would recommend setting your JDK manually in Preferences / Java / Installed JRE, as well as Preferences / Java / Installed JRE / Execution Environment.

然后,只要您需要具有该精确配置的eclipse,只需将该文件与您的预设配置文件,并启动eclipse。

Then, whenever you need an eclipse with that exact configuration, just copy over this file with your preset config file, and launch that eclipse.

从该配置文件中提取:

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\=""/>

这篇关于以编程方式配置Eclipse安装的JRE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆