Related questions

2 Answers

Java uses classpath to search for any class files, jars or resource files that you may have used in your java programs or those you may require implicitly in your java programs.

for setting the classpaths you have 2 options : you may either set them while compiling and running java programs or by defining a classpath environment variable.

for your case you need the basic set up to run java programs which is given below :

1. Go to start>settings>control panel>system. Click on the advanced tab and then click on Environment variables.

2. under user variables click on New. in variable name give classpath & in variable value give c:\j2sdk5\bin if your j2sdk(give name of the installed j2sdk folder) is installed in c drive. click ok.

3. repeat step 2 for system variables.

4. in the same way as step 2, for both user & system variables create another variable with name java_home & value c:\j2sdk if your j2sdk(give name of the installed j2sdk folder) is installed in c drive.

5. under system variables click on path variable and then edit(do not click new). then go to the end of variable value & after the written contents write .;c:\j2sdk5\bin

if your j2sdk(give name of the installed j2sdk folder) is installed in c drive. click ok.

6. click ok 2 times on the 2 screens. then go to command prompt and write javac. if it doesn't give any error then your problem is solved.

step 2 & 3 sets up your basic classpath settings. the remaining steps are used to completely set up your j2sdk. if you have to use any jar file in your programs you can add them in classpath variable.