Having Java installed on your system enables you to run and possibly compile Java programs. If your system does not know where to look for it, however, you will not be able to use these features as simply.
Java JDK installed on Windows or Linux.
Once Java is installed, locate the installation directory, such as:
Next, we have to add the sub-directory \bin to the system’s environment variables. Right-click My Computer, then click Properties, then Advanced System Settings, then Environment Variables. Go to the Path system variable entry, and press Edit. You may see a rather long list here. At the very end, add the following:
If this is not the location of the \bin directory in your Java installation directory, you may change it to your actual path. Press OK. Next, look for the JAVA_HOME system variable in the same Environment Variables list. If it is not there, press New. Name the variable JAVA_HOME, and as the variable value, add:
C: \Program Files\Java\jdk1.7.0_21
This is the Java installation directory. Again, if this is not correct, you will need to use the appropriate path. Press OK. Now, from a command line, type one of the following:
At this point, you should see the help information for both commands, instead of:
‘java’ is not recognized as an internal or external command, operable program or batch file.
Upon gaining access to the command line interface (CLI), locate the installation directory of Java. Once this is done, type the following:
Then, once the .bashrc configuration file is open, press i
This will bring you into insert mode. Once you are in it, move the arrows around until you get to the end of the file. Then, type the following:
PATH=$PATH:/path/to/Java/installation/bin JAVA_HOME=/path/to/java/jre/bin export PATH export JAVA_HOME
The first directory should be the path to the bin directory in the jdk. The second path should be the bin directory in the jre. Then, type the “escape” button, followed by:
Upon restart, you will have Java in your path, set by your environment variables.