Reputation: 35213
I am trying to build a simple java program which creates a db file, then a table and inserts dummy values in the table. I found this page http://www.zentus.com/sqlitejdbc/index.html and tried out the example given on the page but I am getting the following error -
Exception in thread "main" java.lang.NoClassDefFoundError: Test
Caused by: java.lang.ClassNotFoundException: Test
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Test. Program will exit.
Upvotes: 2
Views: 1388
Reputation: 6817
Are you sure you're building the test correctly? Here are the steps you'll need to take:
javac
to compile Test.java into Test.classYou should see:
name = Gandhi
job = politics
name = Turing
job = computers
name = Wittgenstein
job = smartypants
as output.
Upvotes: 1
Reputation: 1499810
Well that looks like it's a matter of the classpath not being right.
My guess is that you're
If you've put something like
java -cp sqlitejdbc-v056.jar Test
then you probably just need to add the current directory to the classpath:
# Windows
java -cp sqlitejdbc.jar-v056;. Test
# Unix
java -cp sqlitejdbc.jar-v056:. Test
Having looked at that page, my guess is that you used : as the classpath separator, as shown on the page, rather than ; which you need to use if you're on Windows.
Upvotes: 1