English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Firstly, when installing Java in the system, you need to set the environment variables, that is, path and classpath.
PATH-The path environment variable is used to specify the directory set that contains the executable programs.
When you try to execute a program from the command line, the operating system will directly search for the specified program in the current directory (if any), and then execute the program.
If the program is not available in the current directory, the operating system will verify in the directory set specified in the “PATH” environment variable.
You need to set the path of the compiler (javac.exe) and JVM (java.exe) existing in the JDK's bin folder.
CLASSPATH-The classpath environment variable is used to specify the location of classes and packages.
when we try to import classes and packages that are not available in the Java standard library.
JVM will directly verify their current status, if not available, it will verify in“CLASSPATH”directory set specified in the environment variables.
JRE in the lib folder ofrt.jarThe file includes all basic software packages of Java, so you need to set the classpath for this folder.
Set the path-
Open the command prompt.
Copy the location of the javac and java commands, which is the bin folder of the JDK example: C:\ Program Files \ Java \ jdk1.8.0_101 \ bin
Use the SET command to set the path variable under the command prompt-
SET PATH=C:\Program Files\Java\jdk_version\bin
Set the classpath-
Open the command prompt.
Copy the location of the rt.jar file, which is the lib folder of the JDK example: C:\ Program Files \ Java \ jdk1.8.0_101 \ lib
Use the SET command to set the classpath variable under the command prompt-
SET CLASSPATH= C:\Program Files\Java\jdk1.8.0_101\lib