简体   繁体   中英

Why does Java require PATH system variable?

I apologize if this question comes off as absurd-I am new to programming but I've been learning quickly.

Now, of course, you download the JDK as an .exe and then install it. But then you have to add a path system variable (and then it can be tested from the command prompt via javac)-but why do you have to do that? I don't know of any other software or IDE/text editor that requires the manipulation of environmental variables.

The PATH system variable helps to find immediately the executables you need, specifying a set of directories where executable programs are located. Or you have to specify the path where they are located.

So you don't have to add in the PATH each directory in your system where there are executables, but could help in same cases, for example when executables are often used by the user or used by other executables programs.

The JDK has a pletora of executable programs (eg java , javac , jar , jstat , etc.) that are used very very often by developers, IDE and other tools (Maven, Ant, Ivy, etc.), so it is a best practice adding to the PATH the directory where JDK executables are located.

Talking about of environment variables, Java usually has other variables you should take care:

  • JAVA_HOME - Specify the directory where your JDK is installed
  • CLASSPATH - specifies the location where are jars, classes and packages.

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