External Jar Library
I have encountered a problem when packaging my code into a .jar file. I have been using the MigLayout external library and because of that, when the jar is created, double clicking on it does nothing. Is there anyway to include miglayout in the .jar file?
You distribute both jars, and place the third party jar in a directory beside or under your jarfile and configure the manifest file to reference it. If you are using an IDE, this is done automaitaclly already and you need only grab and distribute the entire directory containing the produced jar. See Lesson: Packaging Programs in JAR Files (The Java™ Tutorials > Deployment)
I am using JCreator and my jar creation command is
"cvfm RRegistration.jar manifest.txt *.class".
So to add the external library I would change it to
"cvfm RRegistration.jar manifest.txt *.class miglayout-3.7.1-swing.jar"
and then change the manifest file to what? My Current manifest file is
I tried adding the external MigLayout library to my jar at the base level by using the second statement above, but then when I run the newly created RRobotics.jar through the command line, it returns "NoClassDefFoundError: net/miginfocom/swing/MigLayout" which is the external class I was using in my code.
You don't jar a jar.
You distribute your jar file, and those it is dependent on.
In the manifest you point to where these other jars are to be found.
This usually results in a directory looking something like:
-> the other jars referenced by the manifest.
And you seemingly did not read anything I wrote, nor the tutorial I linked to.
Originally Posted by a13w
I am sorry, I read your post and read through the entire tutorial but I did not understand what you meant by "distribute". I have solved the problem, I tried placing my classes in a package before jar-ing it. I then pointed right next to the jar to find the external library.
Thanks for your help, I am really sorry If I seemed to ignore your post or offend you.