PATH and CLASSPATH in Windows7 7 / Eclipse

Posted by Richard Knop on Stack Overflow See other posts from Stack Overflow or by Richard Knop
Published on 2010-05-18T15:01:11Z Indexed on 2010/05/19 8:20 UTC
Read the original article Hit count: 381

Filed under:
|

So I would like to set PATH and CLASSPATH system variables so I can use javac and java commands in the command line. I can just compile and run java programs in eclipse but I would also like to be able to run them through command line.

This is where I have Java installed:

C:\Program Files (x86)\Java
    jdk1.6.0_20
    jre6

And this is where eclipse stores my Java projects:

D:\java-projects
    HelloWorld
        bin
            HelloWorld.class
        src
            HelloWorld.java

I have set up the PATH and CLASSPATH variables like this:

PATH: C:\Program Files (x86)\Java\jdk1.6.0_20\bin
CLASSPATH: D:\java-projects

But it doesn't work. When I write:

java HelloWorld

Or:

java HelloWorld.class

I get error like this:

Exception in thread “main” java.lang.NoClassDefFoundError: HelloWorld

The error is longer, that's just the first line.

How can I fix this? I'm mainly interested to be able to run compiled .class programs from the command line, I can do compiling in the eclipse.

© Stack Overflow or respective owner

Related posts about java

Related posts about eclipse