Results 1 to 6 of 6
  1. #1
    a13w is offline Member
    Join Date
    Sep 2009
    Posts
    6
    Rep Power
    0

    Default External Jar Library

    Hello!

    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?

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    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)

  3. #3
    a13w is offline Member
    Join Date
    Sep 2009
    Posts
    6
    Rep Power
    0

    Default

    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

    Main-Class: RRegistration

    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.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    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:

    myJar.jar
    lib
    -> the other jars referenced by the manifest.

  5. #5
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by a13w View Post
    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

    Main-Class: RRegistration

    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.
    And you seemingly did not read anything I wrote, nor the tutorial I linked to.

  6. #6
    a13w is offline Member
    Join Date
    Sep 2009
    Posts
    6
    Rep Power
    0

    Default

    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.

Similar Threads

  1. Gwt how to import external gar?
    By trust in forum Web Frameworks
    Replies: 2
    Last Post: 07-14-2009, 04:31 AM
  2. external library help
    By SIAS87 in forum Java Applets
    Replies: 0
    Last Post: 03-28-2009, 03:12 PM
  3. External DTD requirements
    By jwilley44 in forum XML
    Replies: 0
    Last Post: 03-06-2009, 09:25 PM
  4. How to execute external EXE?
    By 2bGeek in forum AWT / Swing
    Replies: 3
    Last Post: 02-21-2009, 12:59 AM
  5. Tell me jar file for library library org.bouncycastle.cms
    By 82rathi.angara in forum New To Java
    Replies: 10
    Last Post: 09-09-2008, 05:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •