Could not compile java program from command line in Windows 7

I set the environment variables Path and ClassPath. But still, I cannot compile HelloWorld.java from the command line. Please help me compile and run java program from command line

CLASSPATH C: \ Program Files \ Java \ jre6 \ lib

Path C: \ Program Files \ Java \ jre6 \ bin \

+3
source share
5 answers

You need to add the JDK directory to your path variable (and not your JRE path, as you do). JDK is usually located in:

C:\Program Files\Java\jdk1.6.0_xx\bin\

Where xxis the update number that you installed. Then just compile HelloWorld using:

C:\Your\dir\where\HelloWorld\Is\>javac HelloWorld.java

JDK, JRE, . JDK , Java Development ( ).

+3

JDK , JRE. JRE Java (JDK , JDK).

JDK, , bin JDKs . Java javac.exe.

+1

PATH

C:\Program Files\Java\jdk1.6.0\bin ( )

JDK bin, bin. .

0

CLASSPATH.

set CLASSPATH =; C: \ Program Files \ Java \ jre6 \ lib;

0
source

You can try writing cd C:\examples\ch01\ATM, then press "Enter" and this will change your directory. This allows you to write, for example java ATMCaseStudy, and then press enter. This should work if you put your C directory with the JDK in the same place.

0
source

All Articles