简体   繁体   中英

JDK for Eclipse(in windows platform)

My qustion is really simple, all in the title.

After some tests I found that by given a JRE/bin directory in the path (environment variable) , Eclipse can run normally with no problem. And Eclipse will never try to find the JRE by using JAVA_HOME variable.

And in eclipse, I know that I can add installed JREs in the window preference and choose a JDK folder instead of a JRE folder. And for each project, we can change the compiler level.

Since Eclipse can also compile the codes, when is JDK used? Debug? or what?

Eclipse uses its own compiler to compile Java code. It is different than the javac compiler that comes with a JDK. In fact, you don't need a JDK to compile and run normal Java projects in Eclipse. A JRE is obviously needed to reference the required Java libraries.

However if you are using Maven or some other tools that sometimes depend on a JDK component, then you need to install a JDK on your machine. For example, Maven has an option to rely on the tools.jar that comes shipped with a JDK.

Eclipse uses the JRE you specified as default or per project settings. This could be a (only) JRE installation or a JRE from a JDK installation.

I think the more interesting question is: When should I use a JDK instead of an JRE?

The JDK includes tool that are not included in the standalone JRE. Eg the javadoc.exe for exporting the documentation from javadoc annotated comments in the code. This Program is not included in a standalone JRE. so if you want to export your javadoc documentation you need to add an installed JRE based on a JDK installation first, so Eclipse is able to use the javadoc tool.

对此做出全面的回答可能有点困难,但是我知道至少对于使用Maven / m2e而言,Eclipse需要在JDK中运行。

首先,eclipse是一个Java代码,如果没有安装java来证明它(以您的个人经验),它将无法运行,将eclipse文件夹复制到其他位置并取消安装JDK并尝试运行jave,否则它会输出错误消息no JDK,但是安装JDK并从复制的位置运行eclipse,这将是第一次询问您有关工作场所目录的信息!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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