Should JAVA_HOME point to JDK or JRE?

对着背影说爱祢 提交于 2019-11-26 19:47:25

问题


I pointed the JAVA_HOME to C:\Program Files (x86)\Java\jre7. It works fine. Afterwards, I unzipped ant and set up the environment variables related to Ant, I got the following error messages after typing "ant -version"

I searched this forum. Looks like one solution is to point Java to JDK instead of JRE. I am not exactly sure whether this should be the solution. In other words, in general, which one should JAVA_HOME point to? JDK or JRE?


回答1:


If you're doing any sort of development, or building with Maven or Ant, you need to point to the JDK (Java Development Kit) where utilities such as javac (the Java Compiler) reside. Otherwise, you can point to the JRE (Java Runtime Environment).

The JDK contains everything the JRE has and more. If you're just executing Java programs, you can point to either the JRE or the JDK.




回答2:


Simply (change to your jdk1.x.x.x_xx)

JAVA_HOME=C:\Program Files\Java\jdk1.8.0_05




回答3:


My JAVA_HOME points to the JDK. If it still doesn't work, check if you downloaded ant for Java 7 and not for Java 6.




回答4:


Generally, it does not matter if you point it at JRE or JDK. It depends on the application which uses it. Ant documentation says you should point it at JDK to get all Ant's features.




回答5:


You can use either the JDK or the JRE but:

JAVA_HOME is used by the launcher for finding the JDK/JRE to use. (JDK is recommended as some tasks require the java tools.)
. ANT_HOME setting


回答6:


as a developer, you should point your JAVA_HOME at jdk to access javac copiler etc. It's good if you can test your program to run on the JRE though. If you are using an app server you often also need the JDK instead of the JRE but that depends on the particular server.




回答7:


Let's keep it simple. Go to settings and search "Environment Variables". Once environment variables window pops up, simply create a new SYSTEM variable by clicking on NEW and then BROWSE DIRECTORY until you locate the install path of the JDK. The JDK should be installed in program files and you will see a JAVA folder and inside the folder is JDK and JRE... If you write code you must select JDK!!! Do not listen to anyone stating JRE will suffice... NO! It will NOT! The proper directory should look like this C:\Program Files\Java\jdk1.8.0_144 it's as simple as that!



来源:https://stackoverflow.com/questions/17601827/should-java-home-point-to-jdk-or-jre

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!