简体   繁体   English

Eclipse:新创建/导入项目的默认JRE

[英]Eclipse: Default JRE for newly created/imported projects

I am using Java 8 and overtime I either create or import a project the JRE System Library is set to 1.5 I wonder why since I have nothing but Java 8 installed. 我正在使用Java 8和加班我要么创建或导入JRE系统库设置为1.5的项目我想知道为什么因为我只安装了Java 8。

I now that I can set a default JRE over 我现在可以设置默认的JRE了

Java->Installed JREs Java->已安装的JRE

This would however set a hard coded path to a specific JDK version. 但是,这将为特定的JDK版本设置硬编码路径。 I do update my JDK here and then and if I install newer versions I would have to think of upgrading this path too. 我在这里更新我的JDK然后如果我安装更新的版本,我将不得不考虑升级这个路径。 The command (I am on OS X) 命令(我在OS X上)

/System/Library/Frameworks/JavaVM.framework/Versions/Current/commands/java_home /System/Library/Frameworks/JavaVM.framework/Versions/Current/commands/java_home

points always the latest installed JDK.Can I somehow make Eclipse use always the directory this command is pointing to? 点总是最新安装的JDK.Can我以某种方式使Eclipse始终使用此命令指向的目录? Or do I have to hard-code the used JRE? 或者我是否必须对使用过的JRE进行硬编码?

You can use an 'Execution Environment' (specified in 'Java > Installed JREs > Execution Environments') when you create your Java projects. 创建Java项目时,可以使用“执行环境”(在“Java>已安装的JRE>执行环境”中指定)。 For Java 8 this would be 'JavaSE-1.8'. 对于Java 8,这将是“JavaSE-1.8”。

You can then just change which JDK is using for the Execution Environment in the preferences without having to change anything in your projects. 然后,您可以在首选项中更改用于执行环境的JDK,而无需更改项目中的任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM