SQLite Java Wrapper/JDBC Driver

I'm trying to install the SQLite Java Wrapper/JDBC Driver from http://www.ch-werner.de/javasqlite/ .

The install seems to have gone ok. But when I try to

make test

java test

I get the error

Unable to load sqlite: java.lang.UnsatisfiedLinkError: no sqlite_jni in java.library.path

Exception in thread "main" java.lang.UnsatisfiedLinkError: version

at SQLite.Database.version(Native Method)

at test.main(test.java:72)

Anyone know how to fix?

Thanks

[517 byte] By [qt4x11a] at [2007-11-27 6:22:43]
# 1

From http://www.ch-werner.de/javasqlite/index.html):

To override the directory where configure looks for SQLite and JDK the configure options --with-sqlite=DIR, --with-sqlite3=DIR, and --with-jdk=DIR can be used. To specify the place where the native library (the libsqlite_jni.so file) shall be installed, use the --prefix=DIR option. The default place is /usr/local/lib, i.e. the prefix defaults to /usr/local. To specify where the sqlite.jar file containing the high-level part and the JDBC driver shall be installed, use the --with-jardir=DIR option. The default is /usr/local/share/java. At runtime, it is necessary to tell the JVM both places with the -classpath and -Djava.library.path=.. command line options.

kevjavaa at 2007-7-12 17:39:55 > top of Java-index,Java Essentials,New To Java...
# 2

Does this look right?

I was able to make test, but when i try to run the classfile I get this error

# java -classpath /usr/local/lib -Djava.library.path=/usr/local/lib test

Exception in thread "main" java.lang.NoClassDefFoundError: test

(I can see that the installer script has installed libsqlite_jni.so in /usr/local/lib)

qt4x11a at 2007-7-12 17:39:55 > top of Java-index,Java Essentials,New To Java...
# 3
Try:# java -classpath /usr/local/lib -Djava.library.path=/usr/local/lib/libsqlite_jni.so test
kevjavaa at 2007-7-12 17:39:55 > top of Java-index,Java Essentials,New To Java...
# 4
When I try java -classpath /usr/local/lib -Djava.library.path=/usr/local/lib/libsqlite_jni.so testI getException in thread "main" java.lang.NoClassDefFoundError: testbut the test class is there$ ls test.classtest.class
qt4x11a at 2007-7-12 17:39:55 > top of Java-index,Java Essentials,New To Java...
# 5

> I get

> Exception in thread "main"

> java.lang.NoClassDefFoundError: test

>

> but the test class is there

> $ ls test.class

> test.class

Your current directory isn't in your classpath, I guess. You'll also want to put the sqlite.jar file in your classpath:

java -classpath /path/to/sqlite.jar:. \

-Djava.library.path=/usr/local/lib/libsqlite_jni.so test

This may be neither here or there, but if you used [url=http://hsqldb.org/]HSQLDB[/url], you wouldn't be having this java.library.path headache ;).

kevjavaa at 2007-7-12 17:39:56 > top of Java-index,Java Essentials,New To Java...
# 6

> When I try java -classpath /usr/local/lib

> -Djava.library.path=/usr/local/lib/libsqlite_jni.so

> test

>

> I get

> Exception in thread "main"

> java.lang.NoClassDefFoundError: test

>

> but the test class is there

> $ ls test.class

> test.class

You should add current directory to the classpath (that is a dot)

kajbja at 2007-7-12 17:39:56 > top of Java-index,Java Essentials,New To Java...
# 7

I'm still getting an error. It looks like it's looking for sqlite_jni - shouldn't it be looking in for libsqlite_jni ?

$ java -classpath /usr/local/share/java/sqlite.jar:. -Djava.library.path=/usr/local/lib/libsqlite_jni.so test

Unable to load sqlite: java.lang.UnsatisfiedLinkError: no sqlite_jni in java.library.path

Exception in thread "main" java.lang.UnsatisfiedLinkError: version

at SQLite.Database.version(Native Method)

at test.main(test.java:72)

qt4x11a at 2007-7-12 17:39:56 > top of Java-index,Java Essentials,New To Java...
# 8
Thanks for your help guys.this seemed to work:java -classpath /usr/local/share/java/sqlite.jar:. -Djava.library.path=/usr/local/lib/ test
qt4x11a at 2007-7-12 17:39:56 > top of Java-index,Java Essentials,New To Java...
# 9

> Thanks for your help guys.

>

> this seemed to work:

>

> java -classpath /usr/local/share/java/sqlite.jar:.

> -Djava.library.path=/usr/local/lib/ test

Good deal, glad it worked out. I thought you had to put the actual library on the java.library.path, so that's good to know. Take it easy, good luck.

kevjavaa at 2007-7-12 17:39:56 > top of Java-index,Java Essentials,New To Java...
# 10
i had the same error (but not with SQLite) , and it turned out i was missing a dll that the library required from the classpath
e3oginosXa at 2007-7-12 17:39:56 > top of Java-index,Java Essentials,New To Java...