Installing the JDK and Setting the Environment Variables

1:26 PM 0 Comments A+ a-

Want to get started with Java and set up your computer for Java, then this post is for you only. Every Java programmer I know starts off with writing the Java programs in any text editor such Notepad and compile and run it using Java tools on command line. But to make sure all goes well, you must need to install Java properly and Set up the environment variables for Java. 

Installing the Java 2 SDK (or JDK)

If you don’t have the Java 2 SDK(Software Development Kit) or simply JDK installed on your system, Follow these steps to install the JDK on your system:
1. Download the latest Java SDK version from the Oracle official site.

2. Now browse the jdk setup file on your computer and double-click on the setup file to open it. Now follow the on screen instructions to install the JDK on your system. JRE is also installed along with the JDK.
3. You can check if the JDK has been correctly installed or not by looking in the C:\Program Files\Java\. You must see the jdk1.6.0_26 folder and jre1.6.0_26 folder in it. 1.6.0_26 is the version of the jdk and it can be different depending upon which version did you download from the site.
4. Now you have successfully installed the JDK, the next step is to set the Environment Variables for your Java (JDK).


Setting up the Environment Variables


1. Right click on My Computer and click on “Properties”. Then in
the Computer Properties window, on the left panel click on the “Advanced System Settings”, this will open the new “System Properties window.”
2. Go to Advanced tab and right down the window, click on the “Environment Variables”.
3. Now in the Environment Variables box, either you can set the variables for local user or for System variables. Local variables will only work for the current user and the System Variables will work for all the users.
4. Now for creating the variable for System Variables so that all the user can use the jdk, Find the “Path” variable in the list and click on Edit button.
5. Now place the ; followed by the path to the bin folder inside your jdk. For example  ";C:\Program Files\Java\jdk1.6.0_07\bin "
6. For local variable, you must create the PATH variable by pressing “New” button and setting its value as " ;C:\Program Files\Java\jdk1.6.0_07\bin; "
7. Now in the local variables, create a New variable “classpath” and set its value to “.” i.e. a single dot.
8. Now you are done and all ready to use the jdk for creating the java applications.


Need for Setting Environment Variables

Need for setting PATH variable:
Setting the PATH variable enables the user to use the java tools given in the bin folder from any directory on your system.
If you don’t set this variable, you can only access those tools from the bin directory only.

Need for Setting the CLASSPATH variable:
Setting the CLASSPATH variable enables your class definition to be found across all the directories. If you don’t set this variable, the program source will compile fine but will show the exception at run time that class definition not found.
So by setting the classpath variable to “.ensures that current working directory is included in the list to found the class definition.

Now, as you have set up the environment variables, you are all set to write your first java program.
After that I recommend you to go through the Java Tutorials PDF books one by one and improve your java programming skills. 
Once you start gaining confidence, you can test your skills by preparing Core Java Projects listed here with the project synopses.  

Currently working at Symantec in Chennai. Previously worked as a Senior Software Engineer at IGATE. Loves to explore new things, loves to code and solve challenging problems with the help of it. Like any other normal person, loves to watch movies, listen to songs (specially when travelling, it is must), getting to know people, travelling and whatever makes me feel good!