Assume, you have freshly installed Java on your computer and testing the installation if it has been properly installed. Usually we execute java -version
command to check which version of java is installed on our system. But, when you run this command and get a message 'java' is not recognized as an internal or external command, operable program or batch file then understand that you have not added java installation folder to your syatem's PATH variable.
Once you add java installation folder to PATH variable then you will be able to execute java
, javac
and other commands from any location, otherwise you will have to go to java installation folder in order to execute java commands.
PATH is a system variable that contains locations of executable files or commands. All executable files and comands then can be executed from any location. Once we install java on our system we must add java installation folder to PATH variable because we will compile java programs from different directories, where they are located. In this case if PATH variable is not correctly set for java installtion directory we will not be able to execute javac
coomand.
Like PATH, there is another variable of similar nature that is CLASSPATH. This variable is set to locate .class
files while compiling java programs in case they have any dependency.
Both, PATH and CLASSPATH are environment variables and we need to set them while working with Java programming language. Following are the differences between them.
Path:
Share this page on WhatsApp