0

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?

1
  • How are you running it now? Commented Jun 25, 2013 at 18:44

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Do i run this from inside the bin folder?
I had assumed that you are running your code from the directory that contains the "src", "lib", and "bin" directories, so that's how I constructed the command line.
Thanks!, i spent close to an hour for this issue since I usually use eclipse. Upvoted and approved ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.