Compiling to a specific JRE with Eclipse

2019-01-07 01:05发布

I have two questions regarding compiling a project in Eclipse to a specific JRE:

1) Properties window for project > Java Build Path > Libraries tab:

If I want to compile to JRE 6 - Should the window show JRE 6 and also JRE 7 as included in the build path? Or is only JRE 6 sufficient?

My current situation - good or bad?

enter image description here

2) I know the steps to compiling a project to a specific JRE:

a- Make sure the JRE is in the installed JREs list in Eclipse.

b- Add it to the Build Path of the project, by clicking 'Add Library' in the window I showed.

c- Setting the Compiler Compliance Level of the project to be the same as the oldest JRE I want my application to be able to run on (the JRE I added to the build path).

This is all good, but I still don't understand one thing: What's the difference is between the JREs in the Java Build Path, and the JRE version set as the Compiler Compliance Level?

1条回答
不美不萌又怎样
2楼-- · 2019-01-07 01:51

Compiler Compliance Level is What you have selected language level from the available one to set for your project.

While The Build Path is a used to create Java classpath.

In The build classpath it is a collection of paths visible or availabel to the compiler when building the project.

The Configure Build Path dialog is used to manipulate a file in your project called .classpath.Which is normally hidden.

So what the Compliance level you have selected your project will go for that particular compliance level execution.

查看更多
登录 后发表回答