即日起在codingBlog上分享您的技术经验即可获得积分,积分可兑换现金哦。

如何改变一个Eclipse项目的JDK版本

栈溢出 Peter Mortensen 92℃ 0评论
本文目录
[隐藏]

1.原始问题:How to change JDK version for an Eclipse project

I need to write a project that’s only compatible with Java 1.5. I have Java 1.6 installed. Is there some form of backwards compatibility to get Eclipse to compile with 1.5?

Do I have to install Java 1.5 to get it to show here? Or maybe there is another way?

Enter image description here.

2.被采纳答案

Click on the Add Library button. It brings your screen to point to the Java location.

Select “Directory“, button right besides JRE home and point to the installed folder location.

Even though you want to just 1.5 compiler project, you can achieve it by changing compiler settings in Eclipse instead of removing 1.6 JRE and add 1.5 JRE.

GOTO -->JAVA--Compiler---> and change compiler level to `1.5` instead of `1.6`

As davidfmatheson suggested,

Just be careful, especially if you’re setting this up for a team of people to work on. If anyone uses anything that is new or changed in 1.6, it will compile, but not run in an environment with JRE 1.5.

3.其他高票答案

3.1.第1个答案

Click on the Window tab in Eclipse, go to Preferences and when that window comes up, go to JavaInstalled JREsExecution Environment and choose JavaSE-1.5. You then have to go to Compiler and set the Compiler compliance level.

Changing JRE

Enter image description here

3.2.第2个答案

Right click project -> Properties -> Java Build Path -> select JRE System Library click Edit and select JDK or JRE after then click Java Compiler and select Compiler compliance level to 1.8

enter image description here

enter image description here

enter image description here

3.3.第3个答案

Eclipse – specific Project change JDK Version –

If you want to change any jdk version of A specific project than you have to click —> Project –> JRE System Library –> Properties —> Inside Classpath Container (JRE System Library) change the Execution Environment to which ever version you want e.g. 1.7 or 1.8.

3.4.第4个答案

See the page Set Up JDK in Eclipse. From the add button you can add a different version of the JDK…

转载请注明:CodingBlog » 如何改变一个Eclipse项目的JDK版本

喜欢 (0)or分享 (0)
发表我的评论
取消评论

*

表情