0
votes

I am unable to run the SQLite sample and it's maddening. I get a complex, multi-line error message including:

Exception in thread "main" java.lang.NoClassDefFoundError:  Sample/jar

...

Could not find the main class: Sample.jar.

I suspect a classpath error might be involved, so here is my classpath (Win7):

.;C:\Program Files\Java\jdk1.6.0_25\lib;C:\Program Files\Java\jre6\lib\;E:\Dropbox\Personal\Development\BlueJ examples;C:\Program Files\Java\jdk1.6.0_25\lib\sqlite-jdb-3.7.2.jar

I am running the command prompt inside the E:...BlueJ examples folder (FWIW a normal "java -jar hello.jar" command prompt runs just fine from within this folder). Can somebody pls help figure out what am I doing wrong?

2

2 Answers

1
votes

Your classpath needs to include a reference to the jar file itself, not just the directory it is in.

0
votes

Sorry, had to start another answer as this one is quite longwinded.

Glad things are working but I think you probably misunderstood what I was trying to say in my previous answer.

The classpath is a series of places that java will look for your classes. If the classpath element is a folder then all .class files in there will be included in the search. Jar files are essentially compressed folders, so you have to include the name of the jar file on the classpath. You can put the actual jar file in any directory you like so long as it is referenced on the classpath (using the full path to the file). In your comment to my other answer you have added the sqlite-jdbc.jar to the classpath file but since you have not reference it with a full file path java will only look in the current directory when you run.

Hope that makes sense - and thanks for the acceptance :)