Usage comparison of Path and ClassPath in java

  • 2021-06-28 09:08:31
  • OfStack

What is Path in java?

After installing Java on your computer, you need to set the PATH environment variable to run the executable easily from any directory (javac.exe, java.exe, javadoc.exe, etc.) without typing the full path command.Video Tutorial Recommendation: Java Tutorial)

For example:

C:\javac TestClass.java

Otherwise, you need to specify the full path at each run time, for example:

C: Java jdk 1.7.0 bin javac TestClass.java

What is java neutralizing ClassPath?

Classpath is a system environment variable used by the Java compiler and the Java virtual machine (JVM).

The Java compiler and JVM use Classpath to determine the location of the required class file, which tells the Java application and JVM where to find the class library.

C: Program Files Java jdk1.6.0 bin

What is the difference between Path and ClassPath?

1. The path variable is used to set the path of all Java software tools and locate the JDK2 binary files, such as javac.exe, java.exe, javadoc.exe, etc.The classpath variable sets the path to the java class, which locates and loads the compiled Java byte code stored in the.class file.

2. In order to set PATH in Java, you need to include JDK_in the PATH environment variableHOME / bin directory.In order to set up CLASSPATH in Java, all directories need to be included in the.class or JAR files required by the Java application.

3. PATH cannot be overridden by any Java;However, CLASSPATH can be overridden by providing the command-line options - classpath or - cp to the java and javac commands or by using the Class-Path attribute in the manifest file of the jar file.

4. The operating system uses the PATH environment variable to find any binary files or commands typed in shell, which applies to the Windows and Linux environments.CLASSPATH only loads class files by the Java class loader.


Related articles: