How to include externel library in JAR file?

Hi all =)
I have a program that uses an external library (in a JAR file) I would like to compile my program as a JAR and have it include the external library that it needs to run, so that the external library would not need to be on the computer running my program. How can I do this?
Thanks =)
Koneko349
Message was edited by:
Koneko349

Ok I was able to make my JAR and launch my application correctly. However whenever I click a button that has a method using my external library I get the following error:
C:\Documents and Settings\Koneko>java -jar D:\Mangment.jar
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/POIFSFileSystem at managment_system.ManagmentGUI.getNextStat(ManagmentGUI.java:569) at managment_system.ManagmentGUI$1.actionPerformed(ManagmentGUI.java:195)
I do not get this error when I run and use my program from within the IDE.
The JAR that has my external library (and has the class for POIFileSystem) is also on my D drive and i referenced it correctly (I think) In my classpath:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
     <classpathentry kind="src" path=""/>
     <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
     <classpathentry kind="lib" path="D:/poi.jar"/>
     <classpathentry kind="output" path=""/>
</classpath>I would really like to get this working and I'm very confused XP

Similar Messages

  • How to include grouplayout in my .jar file.

    Hello,
    I have a program that works great on my comptuer and the one in my lab. I would like to deploy this .jar file to other systems, but these other systems are only running JRE 1.5.0_10-b03. The problem, as I understand it, is that swing.grouplayout first appeared in JRE1.6.XX so these older versions don't have the proper librairies to run this.
    How do I include the grouplayout class with my .jar file. I have searched all over my HDD and cannot find the grouplayout class file to include. Am I on the right track?
    Thanks!
    -- Snow

    Note: This thread was originally posted in the [New To Java|http://forums.sun.com/forum.jspa?forumID=54] forum, but moved to this forum for closer topic alignment.

  • How to Include more than one jar files

    My application uses more than one jar files. And all the jar files i am using are signed. when i include the jar files, i am including them in the resources section of the ".jnlp" file . The section of code looks like this:
    <resources>
    <jar href="utestfw.jar" main="true" download="eager"/>
    <jar href="crimson.jar"/>
    <jar href="jaxp.jar"/>
    </resources>
    <application-desc main-class="utestfw.ObjectBrowser"/>
    The deployment of the application is successful. The jar file - "utestfw.jar" contains the application main class when the application is launched it works, but when i choose the feature which involves the classes of either "crimson.jar" or "jaxp.jar" , the application terminates and the webstart console and the application is closed automatically. Am i wrong in adding the jar files? what is the way to add more than one jar files to the ".jnlp" file.
    Can anyone please help me?
    -Aparna

    I'll post u the jnlp file which i am using. To sign all the jars i've used the same alias ( a self signed certificate using keytool and jarsigner).Here is the jnlp file:
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="0.2 1.0"
    codebase="http://127.0.0.1:8080/healthdec"
    href="testTool.jnlp">
    <information>
    <title>Unit Test Manager </title>
    <vendor>Sun Microsystems, Inc.</vendor>
    <description>A minimalist drawing application along the lines of Illustrator</description>
    <icon href="images/testing.gif"/>
    <offline-allowed/>
    </information>
    <resources>
    <j2se version="1.3+ 1.2+"/>
    <jar href="utestfw.jar" main="true" download="eager"/>
    <jar href="crimson.jar" main="false" download="eager"/>
    <jar href="jaxp.jar" main="false" download="eager"/>
    </resources>
    <application-desc main-class="utestfw.ObjectBrowser"/>
    <security>
    <all-permissions/>
    </security>
    </jnlp>
    Can u please look at the above code and suggest me where i am wrong. Thanks.
    -Regards
    Aparna

  • How to include images on a jar file with WSDD

    Hello there!
    I�m using WSDD 5.7 and I�ve created a build with the "Device Developer Builds" tool to generate a jar file. My project contains a package with images inside, the problem is that everytime I generate the jar file it does not contain that package. Any idea?
    cheers!

    I�m using WSDD 5.7 and I�ve created a build with the
    "Device Developer Builds" tool to generate a jar
    file. My project contains a package with images
    inside, the problem is that everytime I generate the
    jar file it does not contain that package. Any idea?I had the same problem and found a workaorund. See my thread in the WSDD forum for details:
    http://www-128.ibm.com/developerworks/forums/dw_thread.jsp?message=13774631&cat=9&thread=102493&treeDisplayType=threadmode1&forum=277#13774631

  • How do I deploy an external JAR file

    Hello,
    How do I deploy an external JAR file?
    I am grateful for every hint.

    Hi Manuel,
      If you read my blog mentioned in the beginning of the thread, you will note that such solution is not supported in our engine due to number of reasons.
      Please, read the blog and use application library shared among these two applications. You will achieve the same effect. Please note that the using application will need run and deploy-time dependencies to the shared library.
      You should not add files to any of the folders manually or manipulate engine's classpath in such situations.
    Best Regards,
    Georgi

  • How can I get a single jar file with NetBeans?

    How can I get a single jar file with NetBeans?
    When I create the project I get these files:
    dist/lib/libreria1.jar
    dist/lib/libreria2.jar
    dist/software.jar
    The libraries that have been imported to create the project are in separate folders:
    libreria1/libreria1.jar
    libreria2/libreria2.jar
    libreria1, libreria2, dist folders are all located inside the project folder.
    I added the following code to the build.xml:
    <target name="-post-jar">
    <jar jarfile="dist/software.jar">
    <zipfileset src="${dist.jar}" excludes="META-INF/*" />
    <zipfileset src="dist/lib/libreria1.jar" excludes="META-INF/*" />
    <zipfileset src="dist/lib/libreria2.jar" excludes="META-INF/*" />
    <manifest>
    <attribute name="Main-Class" value="pacco.classeprincipale"/>
    </manifest>
    </jar>
    </target>
    Of course there is also the project folder:
    src/pacco/classeprincipale.form
    src/pacco/classeprincipale.java
    Can you tell me what is wrong? The error message I get is as follows:
    C:...\build.xml:75: Problem creating jar: archive is not a ZIP archive BUILD FAILED (total time: 2 seconds)

    This is not a NetBeans forum, it is a JDeveloper forum. You might want to try http://forums.netbeans.org/. I also saw your other question - try looking in the New to Java forum: New To Java

  • How to use external library(in .jar format) in netbeans project?

    How to use external library(in .jar format) in netbeans project?
    Thanks!

    How to use external library(in .jar format) in netbeans project?
    Thanks!

  • How to handle 2 or more .jar files with an applet

    Hey out there
    I have created an ftpClient application that uses "jakarta ftpClient". It works fine as an JFrame application � But when I converted the Application into an JApplet I get the following Exception:
    java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClient
    I have bundled the main application into a .jar file (Application,jar). But I don't know how to handle the 2 jakarta .jar files with my JApplet??
    I Tried to append the 2 jakarta .jar files to the Application,jar with the following code:
    jar cvf Application.jar 1.class 2.class�. commons-net-1.4.1.jar jakarta-oro-2.0.8.jar
    But with the same result / Exception (I have signed the Jar file!)
    Can anyone help me

    Hi i have a question with your application can you down- or upload more files at the same time? Because i'm having problems with my ftp application.
    Here is the link with my problem maybe you can help me. I will be very pleased when you can help me.
    http://forum.java.sun.com/thread.jspa?threadID=5162042&tstart=0
    Thx
    Satanduvel

  • How to install a Application in *.jar file format?

    How to install a Application in *.jar file format?
    I have taken the *.jar file into the device into media folder. but device is not recognizing the file format
    could some one plz provide some suggestion to proceed with this?
    Thanks
    Mohamed Javeed

    I'm having the same problem.  I've put .jar into the 'system' folder but that doesn't seem to make the program work neverless see it on my device.  Help.

  • Loading library from jar file

    Hi all,
    My question is can we load library from jar file using System.load() method.
    ex:
    myJar.jar
    |
    |----com.test.common.Util
    which conatins a method to load library from jar file itself, before that i used to load from File
    |---libraries/MozillaParser/......
    Iam able load from Local system,
    File parserLibraryFile = new File("libraries/MozillaParser" + EnviromentController.getSharedLibraryExtension());
    File mozillaDistBinDirectory = new File("libraries/mozilla.dist.bin."+EnviromentController.getOperatingSystemName());
    MozillaParser.init(parserLibraryFile.getAbsolutePath() , mozillaDistBinDirectory.getAbsolutePath());
    but i am unable to load from jar file
    URL url = ClassLoader.getSystemClassLoader().getResource("libraries/MozillaParser" + EnviromentController.getSharedLibraryExtension());
    URL url1 = ClassLoader.getSystemClassLoader().getResource("libraries/mozilla.dist.bin."+EnviromentController.getOperatingSystemName());
    MozillaParser.init(url.toString(), url1.toString());
    Thanks in advance.

    That's a really confusing post.
    The easiest way to make sure you can use the classes in a jar file is to copy the jar file to the "/jre/lib/ext" subfolder of your JDK. These classes will be visible to all applications.

  • How to make the ear file including the 3rd party jar files without menttion in the System Classpath.

    Hai Sir,
    I am facing one problme in weblogic8.1 while depolying the .EAR FILE.
    Please help me sir.
    Case1)     1) I am using the struts and log4j frameworks and 3rd party jar files with
    weblogic8.1.
         2) I make the ejbs,webapplications and 3rdparty jar files, ear file the following
    dir structure .And i mentioned the Class-path including all jar files in the MANIFEST
    OF EAR FILE.
         While deploying the ear file it is giving following error.If log4j.jar does not
    mention in the Weblogic script file
         java.lang.NoClassDefFoundError: org/apache/log4j/Priority
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:1494)
    at java.lang.Class.getDeclaredFields(Class.java:1073)
    at weblogic.ejb20.deployer.EJBModule.disableImplClassLoader(EJBModule.java:1082)
    at weblogic.ejb20.deployer.EJBModule.setupEJBToImplClassDependencies(EJBModule.jav
    a:982)
    at weblogic.ejb20.deployer.EJBModule.prepare(EJBModule.java:419)
    at weblogic.j2ee.J2EEApplicationContainer.prepareModule(J2EEApplicationContainer.j
    ava:2792)
    at weblogic.j2ee.J2EEApplicationContainer.prepareModules(J2EEApplicationContainer.
    java:1478)
    at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:11
    36)
    at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:97
    5)
    at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.prepareCon
    tainer(SlaveDeployer.java:2571)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer(Sla
    veDeployer.java:2523)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeploy
    er.java:2453)
    at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer
    .java:820)
    at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:
    536)
    at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java
    :494)
    at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:
    25)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)
    Please provide the soluation without mentioning classpath in the weblogic script
    .How to make the EAR file incliding ejbjar,webapplication and 3rd party jar files.
    Thanks & Regards,
    ASHOK SAMRAT
    [email protected]

    Refer to the section
    Handling Utility classes
    http://dev2dev.bea.com/products/wlserver/articles/musser.jsp
    thanks,
    Deepak
    "Ashok Samrat" <[email protected]> wrote:
    >
    Hai Sir,
    I am facing one problme in weblogic8.1 while depolying the .EAR FILE.
    Please help me sir.
    Case1)     1) I am using the struts and log4j frameworks and 3rd party jar
    files with
    weblogic8.1.
         2) I make the ejbs,webapplications and 3rdparty jar files, ear file
    the following
    dir structure .And i mentioned the Class-path including all jar files
    in the MANIFEST
    OF EAR FILE.
         While deploying the ear file it is giving following error.If log4j.jar
    does not
    mention in the Weblogic script file
         java.lang.NoClassDefFoundError: org/apache/log4j/Priority
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:1494)
    at java.lang.Class.getDeclaredFields(Class.java:1073)
    at weblogic.ejb20.deployer.EJBModule.disableImplClassLoader(EJBModule.java:1082)
    at weblogic.ejb20.deployer.EJBModule.setupEJBToImplClassDependencies(EJBModule.jav
    a:982)
    at weblogic.ejb20.deployer.EJBModule.prepare(EJBModule.java:419)
    at weblogic.j2ee.J2EEApplicationContainer.prepareModule(J2EEApplicationContainer.j
    ava:2792)
    at weblogic.j2ee.J2EEApplicationContainer.prepareModules(J2EEApplicationContainer.
    java:1478)
    at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:11
    36)
    at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:97
    5)
    at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.prepareCon
    tainer(SlaveDeployer.java:2571)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer(Sla
    veDeployer.java:2523)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeploy
    er.java:2453)
    at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer
    .java:820)
    at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:
    536)
    at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java
    :494)
    at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:
    25)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)
    Please provide the soluation without mentioning classpath in the weblogic
    script
    How to make the EAR file incliding ejbjar,webapplication and 3rd party
    jar files.
    Thanks & Regards,
    ASHOK SAMRAT
    [email protected]

  • Including a DLL in JAR file (Comm API)

    Writing a little app that interfaces with serial port device using the communications API and I'd like to bundle it into an executable JAR. JBuilder will create the JAR for me fine, but the issue is with the win32com.dll file thats part of the comms API. I need to include this, I don't think its possible to include as part of the executable, but otherwise the DLL needs to be in the windows\system folder. Could I include the dll as part of the JAR archive and then extract it upon runtime? If so how would I go about this?
    Any help much appreciated.

    There is another option. Native libraries need to reside within the java.library.path location. As it turns out, if you, at runtime, grab this property and ADD your own location to it, then set it back in to the System.setProperty() call, it will NOT work. The only way to do it is the -Djava.library.path value that tjmaven suggested.
    However, if you read up on how a native library is found, it uses the ClassLoader.loadLibrary() which calls the protected findLibrary() method. You can therefore extend ClassLoader to find a path yourself.
    One way is to extend URLClassLoader since it has the protection/security stuff AND the ability to look in .jar files for you. Your custom loader is created by a "launcher" class in your .jar file. First, your luancher uses getClass().getProtectionDomain().getCodeSource().getLocation() to get the absolute location of the .jar file its executing within. From there, you open the jar and look for your native library, extract it using the JAR api to a location of your choosing. Now, you instantiate the custom classloader and using this custom loader instance you load the rest of your classes. The main .jar file contains two classes, the launcher and the custom classloader, and contains the native library if you wish to do it this way. The custom classloader, you specify a URL[] of "classpath" entries. You bundle up the rest of your source in a second .jar file that you pass to the URL[] when creating the custom classloader. It will find all your classes in the 2nd jar no sweat. You can even "reload" these classes on the fly by recreating the custom classloader instance if you so wish to add a sort of "reload" feature.
    Now, in your custom classloader, you override the findLibrary() and return the SAME STRING PATH that you used to unjar your native files to. This way, when the JVM asks your custom loader to load the library at some path, you return the right path to find the native files in.
    I haven't verified that this works just yet, but I will soon. Primarily, my plugin engine over at www.platonos.org will support the ability to place native libraries in plugins, allowing you to effectively wrap a native library use as a plugin. Not yet working, but we'll soon have it in place.

  • Load library from JAR file

    Could I ask you guys a stupid question, please?
    I have a library as an JAR file. I build my application as another JAR file, which includes that library file.
    My manifest file is:
    Manifest-Version: 0.1.0
    Class-Path: lib/mysql-connector-java-3.0.17-ga-bin.jar
    Main-Class: com.myappand the build command:
    jar cvfm hello.jar mymanifest -c com  -c libThe result hello.jar file built OK. But when I run it, I have to copy library file to the same folder to the app file.
    Could you tell me how to load the lib file from hello.jar, instead of the lib file?
    Thanks in advance!
    Best regards,
    Lehoanq

    am I right in thinking you've put the mysql jar inside your application jar? jars don't work like that, I'm afraid. it is possible to write a classloader that will load classes from within a jar-inside-a-jar, but it gets rather complicated and messy and isn't worth the hassle to be honest, anyway. we go to some lengths to keep our software modular and separate. imagine, for instance, that a bug is exposed in the mysql driver you're using, and a new release is needed to fix it. the dependency is rooted inside your application, so the whole shebang has to be re-packaged and re-deployed, whereas if your dependencies were inside a lib folder, all that would be needed is to drop the new version of the mysql driver into the lib directory. think "don't put all your eggs in one basket"
    what you want to do is possible, and there are tools around to do it for you, too, but IMHO it's not worth the effort

  • Can I include dlls in a jar file for deployment?

    I have a set of dll's I need to deploy (some kind of database driver needed along with my java application) in a client/server situation. Instead of copying these dll's to the client's system32 folder on windows, can I simply include these dll's in the jar file containing my java applications?

    No it was just to make everything cleaner. But if I have to take them outside of the jar file, then like you say there's no benefit in putting them in there in the first place.
    As for having the dll's in the same directory or a sub directory, how can I load them then? Using the function System.loadLibrary?

  • How to build out the deployment JAR file like Visual Cafe?

    Hi everybody,
    I am wondering if there is tool within JDK could generate the JAR file like Visual Cafe's Deployment function.
    It seems that simply to include those library file (jar file's) in the target Jar could not solve the problem.
    Looking for the reply.

    You must to create your META-INF file.
    see more details :
    http://java.sun.com/docs/books/tutorial/jar/

Maybe you are looking for

  • How do I add an address to my ipod touch for imessage?

    How do I add an address to my ipod touch so I can imessage them?

  • Web Services spontaneous turning off on Color LaserJet CM4540 MFP

    We are using ePrint on four seperate Color LaserJet CM4540 Multifunction printers in a business environment where we elected to activate ePrint in order to allow wireless printing for our iPhone and iPad users. We were able to set it up and get it wo

  • How do I connect an external hard drive to an airport?

    Here what's going on. I have an old aiport, Iomega external hard drive and a Netgear N router. My goal is so connect the external hard drive to the airport via the USB port so I can access my photos through the network. I have a Mac Book pro with a f

  • ABAP: Modifying F110_PRENUM_CHCK form for check printing

    Hi All, I need to modify a standard form F110_PRENUM_CHCK for check printing in SAP Scripts according to specifications.Even in the box lengths and font size etc. May I know how to do that. Can any one provide information in this concern. Its very ur

  • Editing pauses from Sermons

    I have GB08. I'm recording sermons from the audio out of a Mackie sound board with a left and right RCA jacks to a mini plug straight into the iMac. It sounds great recorded as a Podcast track with the male voice instrument. The track is about an hou