0

I have a huge project (Application) with another project inside it (Core). Application has a big set of libraries inside as does Core. I'm using Eclipse and so I'm using the Export Runnable Jar option to create Application.jar but when I run it part of the code uses the Core which has a dependency on an image library within that. When I look inside the runnable jar file all the libraries for the Application project are there but when I look inside the Core project jar file the libraries aren't there. To give you an idea of what I mean the structure I'm expecting looks like this:

Application
  - Core.jar
    + ImageLibrary.jar
    + OtherLibraries.jar
    :
  + OtherLibraries.jar
  :

I'm using Maven to build the projects individually. But I'm not really an expert with Maven as I've only being using it for a short time.

Is it possible to build Application so that Core also has its libraries with it?

Thanks in advance, Alexei Blue.

Alexei Blue
  • 1,762
  • 3
  • 21
  • 36
  • duplicate of http://stackoverflow.com/questions/5000351/adding-jar-libraries-into-jar-file and few other questions – milan Jan 06 '12 at 10:33
  • Check the Manifest inside the executable jar this should include the classpath in use its likely that the jars within core are not included so they are being ignored. – Paul Whelan Jan 06 '12 at 10:35
  • I checked the manifest file but Core wasn't in it (Hopefully I'm right in saying that there is just one manifest file). However Core is declared as a dependancy with my pom.xml so Maven should pick it up. It can access the classes within Core, it's when Core calls a class in the image library that it throws a ClassNotFoundException. – Alexei Blue Jan 06 '12 at 10:52

2 Answers2

0

In your Maven build for Application, is Core not specified as a dependency? If so, it should be included with all its dependencies. You should probably check whether the dependencies themselves have the correct scope in Maven to be included.

TrueDub
  • 5,000
  • 1
  • 27
  • 33
0

Okay so I figured this one out in the end. When I was using Maven to build the project it was doing so and then not updating the build path in eclipse. So I in the core directory I ran:

# mvn clean install 
# mvn eclipse:eclipse

As the image library was an addition to the Core dependencies I had to ensure that the build path for eclipse was set otherwise eclipse won't pick up the changes. The eclipse:eclipse command did this for me but I think it only works in projects that are one module, however it reads any dependencies from your pom file and ensures your project can see and access them.

And then in the App directory I re built the project:

# mvn clean install

Then from within eclipse I exported the App project as a Runnable Jar which worked fine.

Hope this helps anyone having the same problem.

Cheers, Alexei Blue.

Alexei Blue
  • 1,762
  • 3
  • 21
  • 36