Tuesday, August 30, 2005

Java - Class Not Found Error

there are 2 reasons you might want to check,

1. u might have to specify pacakagepath.class name while running the class using java command

2. check if the running version of JVM in ur machine, if you have compiled in Java1.4 and running on Java 1.5 you might face this problem.

3. This occurs because the classpath is not setup or referenced correctly.

Executing your program using this command should correct the problem:
java -classpath . helloworld

4. Most importantly please check your Classpath in the System-Env Variables in Windows, the CLASSPATH veriable should look like this %CLASSPATH%.;C:\Your\Path;. If it is not like that, then you will have only on path in your classpath, and hence you are having tought time figuring out why it is not working for your class. but if you try with java -classpath /your/path option it works, this is bcoz when you specify tht it over rules all other paths, but thts the only path there.