0

My application relies on two external libraries, I have both in jar format and have added them to my classpath, making it possible to run my application within NetBeans.

However, I would like to package my application in an easy to use jar file. When I tried the automatic method of jar creation provided by NetBeans (where it auto generates a jarfile in dist/) and ran it on another computer, I got lots of ClassNotFound (or similar) exceptions for classes that I could tell were supposed to be provided by my other libraries.

Is there a way I can include the other jarfiles I have into my own jar? I've never created an application which relies on other libraries before so this is a first for me.

  • 1
    I've never distributed using Netbeans IDE, but if helps I used [ant](http://ant.apache.org/) scripts to do so. It feels more comfortable to me when it comes to this kind of library packaging, file moving/copying,etc. – frarees Nov 30 '11 at 23:40
  • Did you see http://stackoverflow.com/q/8277038/95186? – Eric Rosenberg Dec 01 '11 at 02:45

1 Answers1

1

You can add a "Class-path" line to your jar's manifest. The drawback is that you have to hard code the paths to a file system (not jar) location in the manifest. If you put them all in the same directory or a consistent relative directory, it should be manageable.

See: http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html

Alternately you can try something line One-JAR: http://one-jar.sourceforge.net/

Nialscorva
  • 2,924
  • 2
  • 15
  • 16