File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Jackcess; CLASSPATH? Jar? What?! I just don't get it! (java.lang.NoClassDefFoundError) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Jackcess; CLASSPATH? Jar? What?! I just don Watch "Jackcess; CLASSPATH? Jar? What?! I just don New topic

Jackcess; CLASSPATH? Jar? What?! I just don't get it! (java.lang.NoClassDefFoundError)

Orgar Steinblokkur

Joined: Jul 01, 2010
Posts: 3
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 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><>
at Tester.main<>

I went to 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:

My classpath is:

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.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")
.addColumn(new ColumnBuilder("b")
newTable.addRow(1, "foo");

catch(Exception e)

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...?
Thomas Young

Joined: Jul 17, 2008
Posts: 29
I know nothing about jackcess but you could be missing a jar in your classpath called commons-logging.jar I suggest you check the jackcess documentation to work out why you are missing this and perhaps other jar's

Orgar Steinblokkur

Joined: Jul 01, 2010
Posts: 3
Thank you Thomas, that did help me get past that obstacle!

I happily downloaded the 'commons.logging' and ran into another missing 'common.lang'... no matter.

The only thing that seems to be working for me, is using C:\Java as a repository for the code and all unzipped jar-files. This can't be "optimum". The book says, that it's possible to import the libraries from jar-files without unzipping them. So how do I go on about this?

And one more thing, why do most beginner examples include "foo"? Like print or write "foo". Is this a Java-community-thing?
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
There is no need to unzip (or unjar) any of the jar files; just add them correctly to the CLASSPATH, not the PATH. In light of that, this doesn't make sense:
My path is:

The PATH is for executables, not for Java classes or libraries.

Nor does this:
My classpath is:

Adding a directory only makes sense if it contains loose class files, and adding a library twice is a problem waiting to happen.

Overall, I strongly recommend NOT to use the CLASSPATH environment variable - it causes more problems than it solves. Use the "-cp" switch for javac and java instead.
Orgar Steinblokkur

Joined: Jul 01, 2010
Posts: 3
Thanks for the help, guys!

Nothing worked, and after changing my paths several times, copying jars hither and dither... I thought of the simple solution of just putting everything as it was supposed to be logically (just like Ulf suggested, really) and then re-boot the machine... it worked!

The problem was probably due to some of the system variables being locked or in use. I read somewhere, that re-booting isn't necessary on XP Pro so I disregarded it at first... guess I shouldn't believe everything I read.
I agree. Here's the link:
subject: Jackcess; CLASSPATH? Jar? What?! I just don't get it! (java.lang.NoClassDefFoundError)
It's not a secret anymore!