Friday 23 January 2015

How to Add Java to Your Class Path


In the last tutorial. We installed the Java Development Kit on our machine. However, in this tutorial, we are going to modify our classpath.

If you look at the above image, you realize that the javac command doesn't work on command prompt. javac is the command use to instruct the computer to compile a Java program.

In order to set your class path in Java, you first need to right click on you computer icon on your desktop and go to Properties.

Select Advanced system settings. It will bring up a System Properties dialog box as shown below: 


Click on the Environment Variables button. It will bring up another pop up like this:


Create a new system variable called JAVA_HOME by clicking on the New button in the System variables section.
This is why I insisted on setting the installation directory to Java in the last tutorial. Click on OK. Now JAVA_HOME is now a system variable.

Scroll down the System variable area and find the path variable.

Click on the Edit button.
Add this to the end without editing anything -> ;%JAVA_HOME%\bin

Click the OK buttons on all the open dialogs.

To test if you are successful, run the javac command again. It should give you the following output:


Congratulations. You can now run Java programs on your machine.


No comments:

Post a Comment