3 Replies Latest reply: Dec 15, 2007 5:24 AM by 807603 RSS

    Create JAR file

    807603
      Hi all,

      I have a little problem when am trying to export my project with embedded additional JAR file located inside a folder called lib.

      To demonstrate my problem I have created another project called Test which contains two classes Main (contains main method)
      and UI (a simple JFrame with a button to close the application). I exported this project by using Eclipse and everything works fine

      But once I added the additional JAR file specialized in Look&Feel (Project>Properties>Java Build Path, click on Add JARs not Add External JARs)
      and export the project again, I got problem.

      Project directory contains after exporting (with the additional JAR):
      - META-INF
                    |_ META-INF.MF
      - lib
          |_ substance.jar
      - com
             |_ test
                     |_ Main.class
                     |_ UI.class
      - .classpath
      META-INF.MF contains the following

      Manifest-Version: 1.0
      Main-Class: com.test.Main

      .classpath contains the following:

      <?xml version="1.0" encoding="UTF-8"?>
      <classpath>
           <classpathentry kind="src" path="src"/>
           <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
           <classpathentry kind="lib" path="lib/substance.jar"/>
           <classpathentry kind="output" path="bin"/>
      </classpath>

      Error Message Details:
      Exception in thread "main" java.lang.NoClassDefFoundError: org/jvnet/substance/skin/SubstanceRavenGraphiteGlassLookAndFeel

      How to add
        • 1. Re: Create JAR file
          807603
          .classpath is an eclipse thing, it has nothing to do with jar files, you need to put all your libs you use into your MANIFEST file, like this

          Manifest-Version: 1.0
          Created-By: 1.5.0 (Sun Microsystems Inc.)
          Main-Class: com.dogself.main
          Class-Path: lib/backport-util-concurrent.jar lib/bcmail-jdk14-132.jar lib/bcprov-jdk14-132.jar lib/checkstyle-all-4.2.jar lib/commons-codec-1.3.jar lib/commons-httpclient-3.0.1.jar lib/filterbuilder.jar lib/FontBox-0.1.0-dev.jar lib/highlighter-2.0.jar lib/htmlparser.jar lib/lucene-core-2.0.0.jar lib/lucene-demos-2.0.0.jar lib/PDFBox-0.7.3.jar lib/tm-extractors-0.4.jar lib/trove.jar lib/log4j-1.2.13.jar lib/commons-logging_1.0.4.jar lib/commons-logging-api_1.0.4.jar
          note that the manifest needs to end in 1 blank line, why? i dont know.
          • 2. Re: Create JAR file
            807603
            Look for an Eclipse plugin called Fat Jar

            http://fjep.sourceforge.net/

            If its compatible with your Eclipse version, you can export a whole project with all its jars with two clicks. Sometimes useful for testing, but I would say that it's better to work with individual jars and add them to the classpath.
            • 3. Re: Create JAR file
              807603
              Thanks for all of you