Link to home
Start Free TrialLog in
Avatar of Explorer060599
Explorer060599

asked on

main exception

hi experts, l'm having a terrible problem. i just downloaded the j2sdk1.4.0 and get it installed in windows me. i had set the path=c:\j2sdk14\bin where i installed the jdk and wrote a simple program to test as follow

public class test
{
        public static void main( String args[] )
        {
                System.out.println("testing");

        }

}

saved as test.java. i ran "javac test.java" and returned no error.then i ran "java test" and return "exception in thread "main" java.lang.NoClassDefFoundError :test". i really do not know what happens. pls help.
Avatar of Mick Barry
Mick Barry
Flag of Australia image

It happens because your class is not in your classpath.
You need to include the directory that contains your class in you classpath.

eg. if your class file is in c:\javastuff\test.class

then use:

java -classpath c:\javastuff test

or if you are in the same directory as the classpath you can use:

java -classpath . test
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Explorer060599
Explorer060599

ASKER

oh..yeah, you are my god. thanksssss so much. dumb me.

No worries, happy to help :-)

http://www.objects.com.au
Brainbench MVP for Java 1
http://www.brainbench.com