Why are Java environment variables configured with path and classpath details

  • 2020-04-01 01:20:25
  • OfStack

When I first learned Java, I only cared about how to do it. Now let's go back to why. Let's start with the initial configuration of environment variables.

Why configure path :
When entering an instruction in the CMD command, first look for the command file in the current file directory, then look for the command file in the environment variable of path, whichever is found first, because the path is configured, you can directly enter Java and javac JDK commands under the CMD command

Why configure the classpath :
If the classpath is not set when the JVM is looking for a class file, it will look in the current path. After setting the classpth, it will only look for the class file under the classpath path
For beginners and yourself as a newbie.

Related articles: