I just started with
java last week and have been reading the book called "Head First Java", it's pretty good for someone like me. Java was pretty easy... till today. I wanted to see if I could connect to Access using Jackcess. Then all these stupid and supposedly redundant question hits me... where do I put the jar-file?! Do I have to change my paths... and mend my ways?
It doesn't say anything about it in the book. Jackcess isn't mentioned specifically in the book, but my point is - it doesn't specifically say what to do with all those interesting libraries you find at sourceforge.net... as a n00b... I've copied the jar to various locations, but the thing still won't run.
My source files (my experiments so far... or more precise... my code-excrements, haha... but not for long, hopefully) are all in C:\Java. The jar file is there too. It's even unpacked under C:\Java\com ... it's... EVERYWHERE!!
The code compiles without error, but it won't run and gives the error:
Exception in
thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.healthmarketscience.jackcess.Database.<clinit><Database.java:84>
at Tester.main<Tester.java:10>
...
I went to
http://jackcess.sourceforge.net/ and tried running a code from that page as an example (it's the one further down)... it compiles, but still gives the same error.
My path is:
C:\Programs\Java\jdk1.6.0_21\bin;C:\Java;C:\Java\jackcess-1.2.0.jar
My classpath is:
.;C:\Programs\Java\jre6\lib\ext\QTJava.zip;C:\Java;C:\Programs\Java\jdk1.6.0_21\lib\jackcess-1.2.0.jar;C:\Java\jackcess-1.2.0.jar
I use EditPlus as an editor, as I want to know how things run before I jump into NetBeans or Eclipse.
The code
------------
import com.healthmarketscience.jackcess.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.nio.*;
class Tester {
public static void main(
String args[]) {
try {
Database db = Database.create(new File("new.mdb")); // this is line nr 10
Table newTable = new TableBuilder("NewTable")
.addColumn(new ColumnBuilder("a")
.setSQLType(Types.INTEGER)
.toColumn())
.addColumn(new ColumnBuilder("b")
.setSQLType(Types.VARCHAR)
.toColumn())
.toTable(db);
newTable.addRow(1, "foo");
catch(Exception e)
{
e.printStackTrace();
}
}
}
------------
So what is it... is it the Classpath that I simply don't understand... do I have to install everything once more or... should I take up on knitting instead...?