Three JRE options for new Java projects in eclipse differ

Source: Internet
Author: User

The protagonist of this article is this very tangled place, at least make me this beginner very tangled ...



Let's take a look at the official explanation (link)

Use default JRE:When selected, the new Java Project Wizard creates a new Java project which uses the workspace default JRE. The default JRE can is configured on the Java > Installed JREs preference page. The project would also use the default compiler compliance which can is configured on the Java > compiler preference PA Eel Click onConfigure Default ...To configure the default JRE and compiler compliance.Use project specific JRE:When selected, your can explicitly specify the JRE to is used for the new Java project. The new project would use a compiler compliance which matches the version of the selected JRE.Use an execution Environment JRE:When selected, you can specify a execution environment to is used for the new Java project. The new project would use a compiler compliance which fits best selected execution. Execution environments can be configured on the Java > Installed jres > Execution environmentspreference page.


In fact, the official explanation should be objectively explained clearly, but he explained at the same time, and brought out the rest of the unfamiliar concept, is this compiler compliance. Well, let's get this compiler compliance concept straight.

First of all, set his place here in Java > Compiler

You can see that setting his parameter description is Compiler compliance level, literal translation is "the compiler obeys the rank". The following Drop-down menu allows you to select the version of the JDK. In fact, this parameter is to set your class's run level , that is, your program is in which version of the JDK to compile, so the resulting class at least on this version of the JRE to run on the line.

As an example:

For example, your JDK version is 1.7, and by default your compiler compliance level should be 1.7, because the JRE is meant to be serviced by programs developed for the corresponding version of JDK. The new JDK provides more functionality, and these features have a corresponding JRE (at least the corresponding JRE) to provide a running environment. So your JDK version is larger than the compiler compliance level version.

This parameter option is provided in consideration of the situation where the currently written program is running in a lower version of the JRE environment. At the same time, in order to be able to successfully guarantee that you can run on a lower version of the JRE, it is obvious that you will not be able to use the APIs provided in the newer JDK.

Finally, you must install the corresponding lower version of the JRE to run this degraded compiled program, or he prompts you to install the corresponding version of the JRE. As pictured.


compiler compliance introduced, the following is said about the construction of these three JRE options to be specific to how to treat.


1. First say use default JRE:

You will notice that when I explain the last picture of compiler compliance, there is a configure ... Jump.

He'll jump here to Java > installed JREs

Here, you can configure the JRE on your computer, as long as you want, from 1.1 to 1.7, of course now there are 1.8, all versions of JRE you can install and add to this by adding buttons next to it. Note that this is the JRE, which has the JDK in name because the JRE is included with the JDK and is not installed independently. The JRE can fit as much as you want, but the JDK is enough.

Each JRE has a check box before it, although a check box, but only one is selected, and the selected is the default JRE.

So, the use of the defaultJRE is when you build a project, and if selected, use this as your build JRE. Just like the one I started with, and gave the hint "currently ' jdk1.7.0_71 '".


2. Then use project specific JRE:

In fact, this option is complementary to the use default JRE . Previously said, you can install many versions of the JRE, Choose the Use default JRE will specify the default JRE for you to build the JRE, but if you want to select other installed JRE, you can select this using project Specific JRE, in the subsequent Drop-down menu, you can select the JRE you want to use.

Also, thecompiler compliance is set to the compilation level of the JRE version.


3. Finally the use of an execution Environment JRE:

This option is the most troubling. You click on the Pull-down menu, and you'll see this scene.


It provides all of the run-time environment options that Eclipse supports (just the options).

According to the official explanation, select this option and your compiler compliance will be set to correspond to the JRE version you selected.

For example, I only have JRE1.7 on my computer, if I select the use a execution Environment JRE, and choose "JavaSE-1.6", then there will be such a hint.


That is, the default compiler compliance compile level is 1.7, that is, the JRE version of my JDK, and the new project will be specified as the 1.6 compilation level.

This seems to be the same as the custom compiler compliance I was talking about, and it seems to solve the warning problem that needs to correspond to a lower version of the JRE.

However, when you have finished building the project, you will see a warning in the problems view.


Well, yes, you still need to install the corresponding version of the JRE.

But, you write "Hello world." "Can still be run. But the perfect Match option is to install a corresponding version of the JRE, where perfect match is from here.


This is the compatible JRE setting that heap of JRE options. If you have more than one version of JRE installed, in the compatible JREs list on the right, the compatible JRE for the left execution environment is listed.

I've installed the 1.7 and 1.8 versions of the JDK, which naturally have the corresponding version of the JRE, and the high version is compatible with the lower version, so all of the lists have these two options. But for JavaSE-1.7, the most perfect match of course is corresponding to their version of the JRE. And his version, unless you also have the corresponding JRE installed, you can not find the perfect match JRE.

Also, if you want to specify the default compatible JRE for a JRE in execution environment, check the checkbox before the JRE on the right.


So, to sum up, is:

1. If there is only one version of the JRE on the computer, because you are a beginner, a novice developer, or if your development requires only one version of the JRE, then you can choose use default JRE: on it. Because your eclipse's startup use is this JRE, it will configure the JRE as the default JRE, and usually this JRE is the JRE in your JDK, and it's all so logical.

2. If you have more than one version of the JRE on your computer, you can use the using project specific JRE: to select the JRE you want to use. This time, because your JDK and JRE versions may not correspond, compiler compliance will be adjusted to the version of the JRE you selected.

3. As for use an execution Environment JRE: This option, if you want to select the version of the JRE has been installed, then you can be assured of choice. Or you will not escape this warning.


In fact use project specific JRE: and use a execution Environment JRE: These two options are to help you choose a different JRE, the former is to let you choose from the existing JRE, So you have what he gives you, the more reliable, and the latter is to let you choose from the JRE he can provide, what he can provide, you can choose what, but after the election you have no corresponding JRE that is another matter.


Finally, say a little more. I've installed the 1.7 and 1.8 versions of the JDK before, so there are two JRE versions. The problem is that I use Eclipse's highest support to the 1.7 version of the JRE, so even if I use the 1.8 JRE to create the project, his compiler compliance can be adjusted to the new features in 1.7,1.8. So 1.8 can only unload, and then use the new eclipse to support 1.8 bar (online has a tutorial installed Plug-ins can support 1.8, do not want to toss the:-P).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.