开发者

Why Eclipse does not see .jar file of a library?

I have a java project in which I have "Referenced Libraries". In the "Referenced Lib开发者_如何学Craries" I have a .jar file of a library that I use (I use only one external library).

When I try to "Run -> Run" the code I have a NullPointerException. From my previous experience I know that it it (very likely) because my code does not see the library.

I just started to use Eclipse and it can be the I do not "connect" libraries in a correct way. Should I use some options or additional action to force Eclipse to see the .jar file of the library?

ADDED:

By the right click on the library I get a drop-down menu in which I see "Build Path". My be I need to do something there?


Have you tried this? http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29

Add the library's to your build path :]


External JARs should be added with Java Build Path -> Libraries -> Add External JARs.

Generally the lack of wavy red lines under your class references will tell you Eclipse has recognised the JAR ok.

Depending on your target type (you don't say) there may be additional steps to deploy the JAR.

Many things can cause a NullPointerException. It would be useful to see the full error and callstack. In my experience, missing library content manifests as ClassNotFoundExceptions.


Are you sure it's the missing Jar?

NullPointerException will not usually happen if you have a missing jar For that you may get a ClassNotFoundException or MethodNotFoundException

Adding a breakpoint for NullPointerException in eclipse will tell you when it happened


For me it happened the case where I already added the JAR and Eclipse still did not notice them, then I went to project properties -> Java Build Path -> Libraries and removed wrong references.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜