Reputation: 523
I 'm trying to run a simple java program but I keep getting a NoClassDeffoundError. My directory structure is as follows;
/src/atlasAPI/AtlasService.java
/src/DatabaseClient.java
/lib/<some jar files>
/bin/DatabaseClientTest.class
/bin/AtlasService.class
The DatabaseClientTest class has the main method.
How do I run the program from the command line?
Upvotes: 0
Views: 76
Reputation: 178353
You need to include in your classpath every class that is needed, including your jars in the "lib" directory and your .class files.
java -cp lib/*:bin DatabaseClientTest
The "-cp" is the option to include a classpath. "lib/*" means all jar files in the "lib" directory", and "bin" means all class files in the "bin" directory. The ":" separates multiple parts of the path, assuming you're on Unix/Linux.
Here's the link to the Java Tutorial on Classpath.
Upvotes: 1