Java Swing Tutorials - Herong's Tutorial Examples - Version 4.20, by Dr. Herong Yang
Adding JDK "bin" Directory to Path Setting
This section provides a tutorial on how to add JDK 'bin' directory to the 'path' system envirnoment variable.
In order to run Java compiler and JVM by typing their program file name without the directory path name, I updated the "path" environment variable on my Windows computer:
Then I ran the "echo %path%" command in a new command window to confirm the change:
C:\hreong>echo %path% C:\Progra~1\java\jdk-12.0.1\bin; C:\WINDOWS\system32;C:\WINDOWS; ...
Now I should be able to run Java commands without the directory path name:
C:\herong>java -version java version "12.0.1" 2019-04-16 Java(TM) SE Runtime Environment (build 12.0.1+12) Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing) C:\herong>javac hello.java C:\herong>java Hello Hello world!
Now I am ready to play with Java tools included in Oracle JDK package!
You can also set a new environment variable called "java_home" to avoid typing the full path name to access Java tool program files:
C:\herong>set java_home=C:\Progra~1\java\jdk-12.0.1 C:\herong>%java_home%\bin\java -version java version "12.0.1" 2019-04-16 Java(TM) SE Runtime Environment (build 12.0.1+12) Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
Table of Contents