Powered by Blogger.

Installing and Setting Classpath for Java

>> Saturday, July 6, 2013

Installing and Setting Classpath for Java_JavabynataraJBy seeing this post title you may get doubt. We already installed java and able to run programs also. Why this again? Actually i got a mail from java beginners like they are getting some problem while installing java and setting classpath on their Systems. So just a walk through regarding java installation and Setting classpath.

Let's start our java Installation:
Download Java latest version from oracle. Here i am going to install java 6.0. After downloading Double click on it. The process will start as shown in the below image.
Click on Next button
Installing and Setting Classpath for Java_JavabynataraJ_002
 The default folder will select by Java is: C:\Program Files\Java\jdk1.6.0\
Installing and Setting Classpath for Java_JavabynataraJ_003
 Here Select optional features to install from the list below image. You can change your choice of features after installation by using the Add/Remove programs utility in the Control Panel. here each Tools having option to install default feature and optionally sub features will be installed to local hard drive. you can find it in the  above image.
If you don't want to install you can select "Don't install this feature now" option.
Installing and Setting Classpath for Java_JavabynataraJ_004
 Jdk and Jre both will be installed in two steps.
Installing and Setting Classpath for Java_JavabynataraJ_005
 Click on Next button.
Installing and Setting Classpath for Java_JavabynataraJ_006

Installing and Setting Classpath for Java_JavabynataraJ_007
 Java installation done.

Set Classpath using Commnad Prompt:
Now Let us configure Classpath using Command prompt. Open Run(Win+R) type 'cmd' to open Command prompt.

Create a folder as jprogs under D:\ drive as

D:\cd jprogs

This folder contains your all java programs.

D:\jprogs> set path=%path%;C:\Program Files\Java\jdk1.6.0_26\bin

this tells us the system where to find JDK programs.

Use this command to compile java program:

D:\jprogs\javac HelloWorld.java

After compiling your programs using javac.exe you can see the class file among java file. Then run java file as

D:\jprogs\java HelloWorld

This runs the java interpreter. You should see the program output immediately.If the system cannot find find javac, check the classpath and set correctly. If javac runs but you are getting errors then check your java syntax or text.It may have some spelling mistakes or Capitalization mistakes. Be careful, Java is Case Sensitive.

Make your classpath permanent:
In Windows XP, go to Control Panel, choose "System," click on the "Advanced" tab, click on the "Environment variables" button. In the lower list, "System variables", click on Path:


Installing and Setting Classpath for Java_JavabynataraJ_008

Click "Edit" and append at the end

;C:\Program Files\Java\jdk1.5.0_09\bin

(or the path to the appropriate folder where the latest version of JDK is installed).  Do not put spaces before the appended path string.

Click OK on the path edit box and OK on the Ennvironment Variables box.  The new setting will go into effect next time you run Command Prompt.

Reference Books:

About Author

My Photo
GeekDude
Hi, this is Muralidhar from Chennai.I like blogging on some known things. Trying to provide some basic information for java beginners.
View my complete profile

Random Posts

© javabynataraj.blogspot.com from 2009 - 2014. All rights reserved.