开发者

Java Build Path question

When editing JRE System Library item in Java Build Path we can choose among items in Environments or we can pick Alternate JRE (Installed JREs).

In my case, in installed JREs I have jdk1.6.0_25 and jre6.

What is 开发者_C百科the difference? And when should I reference one versus another one.

Thanks.


The JDK is the Java Development Kit, and the JRE is the Java Runtime Environment, if you are going to be writing code then you need the JDK and JRE to run it, otherwise just the JRE.


JDK (Java Development Kit) contains an embedded JRE (Java Runtime Environment) and the development tools (javac, etc).

JRE can run java programs, but lacks the toolchain to (easily) compile and create java programs.


What is the difference?

In Eclipse, there isn't a lot of difference if you are using the Eclipse compiler (ecj) to compile and build your Java projects. However, not all plugins of Eclipse can run on ecj alone. For example, if you use Maven within Eclipse, you'll need access to a JDK; a JRE is insufficient in such a case. The same goes for WTP.

Also, the JDK usually is installed with the sources and Javadocs, so autocomplete and tooltip documentation tends to be more thorough with a JDK than with a JRE. This can be fixed by adding a separate Java API docs zip/jar.

And when should I reference one versus another one.

I believe the above points are sufficient enough to infer that using a JDK is usually better than using a JRE, except for plain Java projects.


If you are talking about Workspace Preferences->Java->Installed JREs, then in your case there will not be much difference.

Both probably point to a version 1.6 of Java VM shipped by Oracle.

These JREs are not used to compile your code in Eclipse ( at least not directly, they are specified as dependencies in project build path->Libraries tab ). Instead they are used to provide an execution environment when you are running/debugging your application.

They start to come in play if you need to test your code running against JREs shipped by different vendors or against earlier versions of Java.

From my experience with Eclipse, you do not need JDK to compile and run programs.

However, it is a good idea to have JDK installed if you are doing command-line builds.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜