Reputation: 245
I have a Java NLP project (say X) in eclipse which has dependencies in maven & also some jars added externally to buildpath.
Now I've built UI to this project(x) using java swing which is another project in eclipse (say Y).
When I run the project Y (which calls project X when a button is clicked) is throwing me errors like
java.lang.NoClassDefFoundError: edu/stanford/nlp/ie/NERClassifierCombiner
which I think is because, project Y is not able to find/recognize the external jar that I've added in project X.
I've tried adding all those external jars to Project Y's build path too but nothing worked.
Can you please help me figure out how to handle these dependency issues. Been struggling since 4 days.
Thank You.
Upvotes: 1
Views: 135
Reputation: 1155
I faced similar issue. But I figured out that my problem was with maven dependencies but not with the external jar.
In my case, I did not create the main project (i.e. your Y) as a Maven project which was why it wasn't working. Moment I converted it (Y) to Maven project, my code started working like magic.
I just had to add the lib
folder of project X in project Y too.
Hope this will solve your issue too.
Upvotes: 0
Reputation: 1992
You need to add external jars via maven first. I can think of three ways to do that.
<repository> <id>lib</id> <name>lib</name> <releases> <enabled>true</enabled> <checksumPolicy>ignore</checksumPolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> <url>file://${project.basedir}/lib</url> </repository>
<dependency> <groupId>myjar_1.0</groupId> <artifactId>myjar_1.0</artifactId> <scope>system</scope> <version>1.0</version> <systemPath>${basedir}\src\lib\myjar_1.0.jar</systemPath> </dependency>
Second and third method is highly discouraged to do though.
Also, consider making a fat jar using maven shade plugin, so that, all required jars are present into your jar already.
Upvotes: 1