External Jar files packaged with the Application Jar.

Hello Friends,
I have a Java class 'Config.java' with a package a.b.c
This class requires a third party Jar 'new.jar'. I place this Jar file in the parent directory of the package.
So I can compile the Config.java with classpath as '.'
This works fine.
Now while packaging them, I create a mymanifest.mf file with following contents
Main-Class: a.b.c.Config
Class-Path: . new.jar
and issue the command
jar -cvmf mymanifest.mf myjar.jar *
This creates a jar file with appropriate manifest information and heirarchy (since the included third party jar is in the same directory)
When I run the Jar by issuing the command
java -jar myjar.jar
It gives me an error, NoClassDefFound for a class inside the included third party jar.
I have gone through some of the other queries posted in this forum and through Sun's articles for creating Jar files.
I have taken care of all the minute things involved in writing the manifest file, etc.
I dont understand why such a simple application gives me a problem.
Am I still missing something ?
Regards,
Ravi

I had the same problem. But I solve it.. The thing that you have to do is:
create another directory in your project application directory let's say your project directory is Project. such as Project / lib.
then put external jars in lib directory.
The last thing you have to do :
change your manifest file like that
Main-Class : mainclass
Class-Path : lib/externaljar1.jar lib/externaljar2.jar
I don't know you ever deal with manifest files before but there can be very stupid errors while you create .
i.e there should be a space between ":" and mainclass name you shoul use "/" not "\" etc.
I think it will work for you.

Similar Messages

  • Unable to access classes in third party jar files packaged with my ejb.jar

    I have packaged some third party jar files in my xxx_ejb.jar file.  The third party jar file contains classes that are accessed by some custom classes which are in turn accessed by my bean classes.  I get the following error when my custom classes attempt to use any of the classes in one of the third party jar files:
    java.lang.NoClassDefFoundError: com/Ostermiller/util/CSVParser
    Shouldn't I be able to access classes in jar files that are packaged with my xxx_ejb.jar file?  I see the xxx_ejb.jar file as a resource of the application classloader that contains it but I don't see the third party jar files.

    As per the Java EE specification, additional JAR files should be packaged on the EAR level. Only WAR files' WEB-INF/lib folder is scanned for JAR files to be added to the classloader.

  • Can .air installer some files together with the application?

    I have an installer.air that is created by Adobe Flash. I have another file called settings.cfg which is needed for my application to run. How do let the computer auto install settings.cfg into the installation directory together with the application when i run installer.air? Currently, I need to manually place the settings.cfg into the application installed directory.

    YAY Thanks, kglad.

  • Deploying jar files along with my application

    Hi
    My application uses the Apache Batik classes to do some converting of SVG files. The Batik classes recides in 20 jar files, which I've loaded as libraried in Netbeans and when I run my project in Netbeans all works great. But if I build by project and try to use it in a different java application, I get the error:
    Exception in thread 'main' java.lang.NoClassDefFoundError: org/apache/fop/svg/PDFTranscoder
    I've tried everything: to include all the jar files in my own jar file ... to use a manifest file ... to deploy my application as a single class file instead of a jar and so on. But nothing helps.
    Any ideas?

    Hi
    Already tried that. If I'm not distributing my application as a jar file, but rather as a single class file, how would I do then? I mean, there would be no manifest file at all.

  • Deploying an application with existing library as jar file created with ANT

    Hello All,
    I am having some trouble with a web application I am deploying to Tomcat. I have an custom library that works perfectly as a jar file included in the lib directory if I include all the jars that that library depends on into the lib directory also. What I would like to do is bundle the required jar files into my libraries jar file, but it failes to work when I do that.
    Any thoughts? Does Tomcat prevent this?
    I am using ANT to create my jar file, but when I look at the contents of my jar file it includes all the requested directories.
    My build.xml looks like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <project name="myapp" basedir="." default="jar">
    <property name="classes.dir" value="./classes"/>
    <property name="jar.dir" value="."/>
    <property name="java_lib.dir" value="../../../../../Program Files/Java/lib"/>
    <target name="jar">
    <jar destfile="${jar.dir}/${ant.project.name}.jar">
    <fileset dir="classes"/>
    <fileset dir="${java_lib.dir}" includes="jai_codec.jar.jar"/>
    <fileset dir="${java_lib.dir}" includes="xercesImpl.jar"/>
    <fileset dir="${java_lib.dir}" includes="mysql-connector-java-3.1.8-bin.jar"/>
    <fileset dir="${java_lib.dir}" includes="xmlParserAPIs.jar"/>
    <fileset dir="${java_lib.dir}" includes="mlibwrapper_jai.jar"/>
    <fileset dir="${java_lib.dir}" includes="xml-apis.jar"/>
    <fileset dir="${java_lib.dir}" includes="jai_core.jar"/>
    </jar>
    </target>
    <target name="run" depends="jar">
    <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>
    </target>
    <target name="clean-build" depends="jar"/>
    <target name="main" depends="run"/>
    </project>
    Like I said...it includes these jar files in my jar file, but will not function properly with my tomcat app. If I exclude these jar files and include them seperately then everything works.
    NOTE: I do not access any of these libraries directly from any servlets, only from my classes.
    Thanks,
    J-Rod

    This probably isn't posted on the correct forum. This JVM forum is for discussing issues related to running java in an Oracle database using the OJVM, Oracle's embedded java VM. Possibly you are trying to use OJVM through JDEV but that isn't clear from your post and I don't believe that the error you are reporting would occur in that case. If it did or if you are in fact trying to run client java via JDEV the problem would be a JDEV rather than OJVM issue and so the JDEV forum,
    JDeveloper and ADF
    is the correct one to use.

  • How To Access a jar file present outside the war file through a jnlp

    Aoa
    I m new to this forum
    I m having problem with my jnlp file
    i want to know is there any way to access a jar file through jnlp.The problem is that my jnlp file is present in the war file
    and i want to know how to acess a jar file through this jnlp.The scenerio is as below
    I m using ear file on jboss.Its hirerchy is as
    -PAN-war.war
    -launch.jnlp
    -PAN-app-client.jar
    my jnlp file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://localhost:8080/" href="PAN/launch.jnlp">
    <information>
    <title>PanEmirates</title>
    <vendor>M Fazal Ur Rehman</vendor>
    <description>PanEmirates</description>
    <description kind="short">PanEmirates</description>
    <homepage href=""/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.5+"/>
    <jar href="PAN-app-client.jar" download="eager"/>
    <jar href="lib/javafxrt.jar" main="true" download="eager" />
    <jar href="lib/Filters.jar" download="eager"/>
    <jar href="lib/javafx-netbeans-fxuserlib.jar" download="eager"/>
    <jar href="lib/swing-layout-1.0.3.jar" download="eager"/>
    </resources>
    <application-desc main-class="net.java.javafx.FXShell">
    <argument>pan.Main</argument>
    </application-desc>
    </jnlp>
    when i run launch.jnlp file it says unable to download resource http://localhost:8080/PAN/PAN-app-client.jar
    how to access this jar file
    Any help or comment would be highly appreciated
    Regards
    M Fazal Ur Rehman

    Excellent question. I don't see any client-jar in your EAR file structure. So I am assuming you are writing a separate client application which will talk to the ejbs deployed as part of this EAR. You need to do the following:
    Write another EAR file with the following structure:
    ear:
    META-INF/application.xml
    util.jar
    client.jar
    client.jar should have a META-INF/MANIFEST.MF and that should contain Class-Path:util.jar and value for Main-Class attribute.
    Now deploy this new ear to your application server and execute it using Application Client Container that comes with your app server.
    If you don't want to write another EAR file, then bundle th client.jar in your original EAR file.
    Points to note are:
    you have to repackage util.jar again inside this ear file.
    For portability reason, you should use Class-Path manifest entry in client.jar. Refer to http://java.sun.com/j2ee/verified/packaging.html and J2EE platform spec section #8.2.
    Hope this helps,
    Sahoo

  • Jar File executes without the CLASSPATH being set???

    Hello all:
    I have been writing an application with JBuilder 4.0 Professional. I have finished the program and then let JBuilder create a JAR file. About the first 5 times I created the JAR file, I could never get it to execute from the command line. However, the last time I created the JAR file, I doubled clicked on it and it executed by using javaw. I had the CLASSPATH pointing to the file. I later removed the CLASSPATH variable, and the JAR file still executed. My MANIFEST.MF file includes the package name(not classpath) and the main class(which contains the public static void main method).
    I installed the JAR file and the JRE on another computer and it would not work. Can anyone give me some information??? Thanks in advance.

    probably this is due to the fact on your windows explorer under view - options, File Types tab you have the executable jar file pointing to a jdk.
    click on Executable Jar File and click edit then click on open in the Actions box (if this isn't here then this isn't the reason, sorry) and click edit. a pop up will appear with the java exe path - this is what the app is running from.
    gaz

  • The jar size value in the Application Descriptor does not match the real ja

    Hi,
    when i creat obfuscated package for my application It's posing the
    Error preverifying class A
    Class loading error: Wrong name
    The jar size value in the Application Descriptor does not match the real jar file size.
    It's perfectly working for all the other applications .I tried to change the jar size in the jad file but it's not working.

    Yes, the obfuscator does not change the size value after finishing. You have to do it yourself.
    Mihai

  • Opening a file (hst), executes the main jar file to open the hst file HELP

    Greetings,
    I have created a file with an extension *.hst, so in my Win XP computer, when I double click a .hst file, it should be opened in my program, which is a jar file, so during the installation I associate my program to this .hst file extension.
    After all this, when I double click this .hst file, it shows an error message that the jar file is not a vaid win32 application. I donot wish to convert my file to an .exe. Help ?
    Cheers,
    Raj

    How did you specify command line for your .hst file?
    It should be something like "java -classpath
    [youfile.jar] [youclass] %1"I have not specified command line for the .hst file.
    The .hst file is just a file that is created when my main program (jar file) saves its files., later If I double click this saved hst file, it should be opened in the main jar program.
    For the double click to work, I have created a constructor
    public hst(String hstfile)
       //code to set the file contents in the window.
    }the problem is that when I double click it says that the main jar file is not a valid win32 application, so what do I do ?
    Cheers,
    Raj

  • Getting jar file name with wrapper

    Hi,
    I'm using [java service wrapper|http://wrapper.tanukisoftware.org/] to launch my project,
    with the command
    File jarFile = new File(main.class.getProtectionDomain().getCodeSource()
              .getLocation().toString());witch opens the jar file name, this command returns the following
    file:C:/wrapper/../lib/project.jar
    this string raises the exception java.lang.IllegalArgumentException: URI is not hierarchical
    Is there any other why to get the application jar name ?, thanks

    Hi, the is the answer of my previous question
         public static String getJarNameURI () {
             String pathrojar = main.class.getProtectionDomain().getCodeSource()
                     .getLocation().toString();
             if (pathrojar.charAt(5) != '/')
                pathrojar = pathrojar.replace(":", ":/");
             return URI.create(pathrojar).normalize().toString();
    File jarFile = new File(getJarNameURI ());

  • How to make a jar file downloadable with IE

    hello,
    I just bought a website:
    http://www.frozenfountain.net/
    and I put a jar file on it called Logo.jar
    Using Mozilla, the jar file downloads as expected, but with Internet Explorer, it tries to download it as .zip file.
    How do I get it to download as a .jar file with IE?
    thanks

    Just post a link to the Jar. Mozilla will download
    it as a jar. Windows will download it as a zip.
    Only one link. No problem, really. ;-)There is a problem. People who arent as good with computers as you are won't know how to run the jar file after downloading with IE.
    At school, I told someone to download the file, which they did with IE. It downloaded to desktop as a zip. They extracted and were left with a bunch of .class files.
    On a sidenote, how do you draw text with a gradient?

  • Can we make jar file for simple j2se application

    Hi..Can we make a jar file for simple j2se application so that it can be executed on any system like .exe file...

    Read the JAR files section in Sun's Java tutorial.

  • Jar file downloaded still the old version

    If I update a new jar file in the web server, The jar file being downloaded by a remote pc is still the old jar file even if the java plugin cache has been deleted. In my source below, I have already specified applet option as plugin.
    Below is the source code for applet caching:
    Hope someone could help thanks
    <OBJECT
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    width="0" height="0" align="baseline" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
    <PARAM NAME=<%=IboReserved.SCREEN_BUILDER%> VALUE="com.weserv.ibo.gui.InternetBanking">
    <PARAM NAME="trxcode" VALUE="0">
    <PARAM NAME="langind" VALUE="en">
    <PARAM NAME="country" VALUE="US">
    <PARAM NAME="code" VALUE="McpgApplet.class">
    <PARAM NAME="codebase" VALUE="http://mcpgdev.bancnet.net/apps">
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
    <PARAM NAME="cache_archive" VALUE="<%= appletArchive %>">
    <PARAM NAME="cache_version" VALUE="<%= appletVersion %>">
    <PARAM NAME="cache_option" VALUE="Plugin">
    <COMMENT>
    <EMBED type="application/x-java-applet;version=1.3"
    width="0" height="0" align="baseline"
    code="McpgApplet" name="mcpgApplet" codebase="http://mcpgdev.bancnet.net/apps"
    pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html">
    <NOEMBED>
    </COMMENT> No Java 2 support for APPLET!! </NOEMBED>
    </EMBED>
    </OBJECT>

    download the zip file unzip it under windows install the drivers you need upgrading
    thats what I did and it updated my video card driver so windows stopped crashing

  • How to list the JAR files loaded into the Oracle Database ?

    How to list the JAR files loaded into the Oracle Database ?

    From 11.1 onwards, the below two views are available to identify the jar files loaded into the Database.
    JAVAJAR$
    JAVAJAROBJECTS$
    By querying the JAVAJAR$ view you can know information about the JAR files loaded into the Database and using JAVAJAROBJECTS$ view you can find all the java objects associated with the given JAR file.
    These views are populated everytime you use LOADJAVA with "-jarsasdbobjects" option to load your custom java classes.
    But unfortunately this feature is available only from 11.1 onwards and there is no clear workaround for above in 10.2 or earlier.

  • The application "Jar Launcher" can't be opened

    When I am open a Jar file, it aways say: The application "Jar Launcher" can't be opened, then it says: "-1712" I am using the most update Java. I am also using Marvelicks OSX 10.9.5. My computer doesn't have a lot of issues. May someone help me?

    Restart the computer and try again.

Maybe you are looking for