开发者

Eclipse not able to find org.sqlite.JDBC (Java)

I'm new to Eclipse. I'm trying to connect to SQLLite database. I'm following examaple from http://www.zentus.com/sqlitejdbc/usage.html. I downloaded the jar file, imported into the project but once I run the code I get following exception

Exception in thread "main" java.lang.ClassNotFoundException: org.sqlite.JDBC
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPriv开发者_运维百科ileged(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)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.amazon.IP2Zip.Test.main(Test.java:7)

Seems like it is not able to find the class, even though I imported the jar file into the project.

Any help would be greatly appreciated :)


right click on the project and select properties from that select build path and there in the libraries section select add external Jar's and browse to the location where the jar file is stored.

Hope this will do the trick


According to the java.lang.ClassNotFoundException ,classes cannot be found in the CLASSPATH. Try to put that path into build path by doing something like this :-

Project->BuildPath->libraries ->Add External jars.


This may not be true for your case, but I just resolved a similar problem that appeared to defy logic. There are a few similar questions on this topic, but all came up short in solving my problem. I figured I'd might as well mention the problem I encountered.

I downloaded the JAR, which I obtained via a quick search. I first tried to include this library via Eclipse, which I'm quite familiar with. I added the JAR to the build path as usual, and proceeded to run my program expecting some silly output that would confirm that org.sqlite.JDBC had been found. Unfortunately, I was instead met with the ClassNotFoundException.

I looked at the contents of the JAR, and sure enough, org.sqlite.JDBC appeared to be there. After that point, I figured I must have done something wrong, and searched up a bunch of similar questions to determine where I went wrong. The only problem was, the majority of them were recommending exactly what I did to begin with! I then considered that perhaps something was funky with my Eclipse setup, so I ran it (specifying the classpath) manually via the command line. Even so, I was met with a ClassNotFoundException.

At the end of my rope, I then considered the possibility of what I had thought was extremely unlikely--that the JAR was somehow corrupted--and this time went directly to the project download page for a fresh copy. On adding the JAR to the build path in Eclipse, I noted that it had a slightly different structure than the one I had previously. Then I attempted to run it and... it worked! So in the extreme unlikelihood that you download a corrupted JAR, that could explain your problem.


I ran into this issue as well. In my project, I wanted to package everything into a JAR file to make a stand-alone application.

The ClassNotFoundException was thrown because I forgot to add the library to my classpath in the MANIFEST.MF file. Adding the line "Class-Path: lib/sqlite-jdbc-3.7.15-M1.jar" to my MANIFEST.MF file solved the problem for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜