JAR File problems

Hello,
I have a jar file with some code I wrote that accesses a jar file from a 3rd party. I want to include the 3rd party jar files inside my jar file. So I basially have a jar file with my code (unjarred) and include the 3rd party jar files in my jar. In my MANIFEST.MF file I have properly set the Main-Class property correctly, as well as the Class-Path property. I have set my Class-Path value to 3rdparty.jar which is the jar file at the root directory of my jar. When I run my jar file I get a NoClassDefFoundError saying the 3rdparty jar file is not found. I have added a new line at the end of my MANIFEST.MF file, and am actually using ant to create my MANIFEST.MF file. When I unjar my file everything looks correct. What is the problem here? I have made sure the 3rd party classes that my code access are in the jar. What could I be doing wrong??

Standard Java does not support placing a jar file within another jar.
You can search for 3rd-party alternatives, ow write your own custom classloader.

Similar Messages

  • Jar File Problem Using External Packages

    I am having problems creating an Executable jar file that imports classes from my own package.
    I can create an exe jar no problem without using any external packages, but when I use an external package the jar will not execute.
    I am using WindowsXP, my package is in,
    C:/MyClasses/Database
    the class files are stored loose, not in a jar file
    I have tried altering the class-path in the manifest file, but to no joy - I may have not changed the classpath correctly!
    Please help
    Magic

    This is a mine field of "correct programming style."
    External jars, if very general, could be placed in the directory jre/lib/ext.
    In some cases you can unzip the external jars and add them to your own jar.
    The manifest.mf migth be looked into, and of course you need to communicate your patching!
    As you remarked, it might be a problem of class path usage.
    For that the jar tool documentation might explain it better than I.

  • Jar file problem , please help

    Hi guys , i am not sure if i am in the right place to have this post in so i'll give it a try
    i know my explanation might be a shot in the dark but i'll try my best
    i have made a program using eclips , to send emails using my email , on certain conditions
    so when that codition happenes on some class in my program
    this class will call the email class and send an email to someone
    now the problem is not in the program , because as along as this program is in eclips and i run the program in eclips , everything goes fine , No errors what so ever
    but , if i make jar file , using eclips "export"
    once i run the program , the program would run , but once the same condition that ihave specified previously happenes , the current class never calls the email class , and no emails would be sent
    i am very confused wether
    1) it throws a class not found for some wierd reason
    2) or the external library that i used to send emails , is not exported
    i tried to check the CLASSPATH file and i think everything seems to be fine , so i dont know what the problem is
    so in short
    if the program is in eclips , every thign goes fine
    if the program is a jar file , then it would work fine but once it needs to send an email , it never does and i can still work on the program , but no emails will be sent
    thanks please some one help me out with this

    for more information here is the senario
    because i see that you guys are some how lost because i am not providing enough information
    so this is a detailed info of the problem
    i have 3 classes
    1) mybankmain (jframe)
    2) mybankbody (all labels and buttons and events included here)
    now: within some events in my program ,
    it calls a class called.....
    3) myEmail
    this class imports two things that are comming from an external jar file , so in short , if the external jar file is not available the program would complain
    i run this on windows xp (SP2)
    now: if this program runs on eclips , it would do everything it is supposed to do and all kind of calculations will be done and emails will be sent on the conditions that i have specified within the program
    if i make a jar file on windows , and i run the jar file , the file would work , all functionalities will work
    EXCEPT: sending an email
    - either my class is not found
    - or external jar file is not found which causes my class not to be able to perform its tasks
    i did only one test
    which is that i switched the main and i made myEmail as a main and i tried to export the jar file
    Result: jar file doesnt work
    the way i view whatever inside my jar file , i use Winrar and it would view everythign in the jar file and i see that all my classes are included there
    if i open my CLASSPATH , i see that there is a pointer to the external jar file
    if i open my manifest : i DO NOT see the exrernal jar file in there but i do see that its pointing to my main class
    class main : mybankmain
    and there is only the version and signiture
    i hope all these additional details would help in determining the problem that ihave been trying to solve for 2 weeks now

  • Hot Deploy Servlet in JAR file problem

    I've been playing with hot deploying servlets in WLS 5.1. I have SP2
              installed. I have things working fine with individual servlet class files. I
              decided to try hot deploying with jar files.
              I created a servlet, added it to a jar file, and then added the jar file to
              the 'weblogic.http.servlet.classpath'. I then restarted the server. I
              started the console and was able to hot deploy the servlet. So far so good.
              My next test is what failed. I modified the servlet, and rebuilt the jar
              file. I went back to the console, selected the servlet and hit the redeploy
              button. I went back to the browser and hit refresh - nothing, still the old
              servlet.
              It appears that WLS isn't reloading the jar file and the updated servlet.
              Everything works with individual class files.
              Does anyone know how I can cause the reload of updated servlets embedded
              within a jar file?
              Weblogic group - If there is no way now, will support be added soon?
              Thanks,
              Rick
              

    Hi,
              If I use weblogic.servlet.ServletServlet to try just the servlet , It
              works correctly.But When I develop it in a web application , there is a lot
              of hypelink to this servlet,thus I can't use the relative path reference to
              that servlet.I try to set the name of weblogic.servlet.ServletServlet same
              as the webapp,It doesn't work,how do I solve this problem?
              Thank you
              Pan
              Subject: Re: Hot deploy Servlet in webapp
              > http://www.weblogic.com/docs51/classdocs/API_servlet.html#134798
              >
              > It even explains why you shouldn't use it in production environment.
              >
              > Dimitri
              

  • Java Access Helper Jar file problem

    I just downloaded Java Access Helper zip file, and unzipped, and run the following command in UNIX
    % java -jar jaccesshelper.jar -install
    I get the following error message, and the installation stopped.
    Exception in thread "main" java.lang.NumberFormatException: Empty version string
    at java.lang.Package.isCompatibleWith(Package.java:206)
    at jaccesshelper.main.JAccessHelperApp.checkJavaVersion(JAccessHelperApp.java:1156)
    at jaccesshelper.main.JAccessHelperApp.instanceMain(JAccessHelperApp.java:159)
    at JAccessHelper.main(JAccessHelper.java:39)
    If I try to run the jar file, I get the same error message.
    Does anyone know how I can fix this?
    Thanks

    Cross-posted, to waste yours and my time...
    http://forum.java.sun.com/thread.jsp?thread=552805&forum=54&message=2704318

  • JAR file problem with windows operating system rare

    hi,
    I have an application created with Eclipse 3.2, which also have a plugin that helps me to create jar files, migrate days ago all my application and my data base to a notebook that has a very rare operating system is Windows Vista, but is a version very rare and never seen, called oneAngel Illusion, and I think that that is not capable of running the JAR correctly, that when you double click or enter to JAR nothing happens, and I prove it on a machine that has XP and functioning properly.
    I hope I can help with this!

    pg_shadow wrote:
    hi,
    I have an application created with Eclipse 3.2, which also have a plugin that helps me to create jar files, migrate days ago all my application and my data base to a notebook that has a very rare operating system is Windows Vista, but is a version very rare and never seen, called oneAngel Illusion, and I think that that is not capable of running the JAR correctly, that when you double click or enter to JAR nothing happens, and I prove it on a machine that has XP and functioning properly.
    I hope I can help with this!You should know, if you don't already, that your 'super rare' version of Windows Vista, sounds like one of numerous, illegal, cracked and knocked-off versions of Vista that have been floating about. Things like Windows Vista Silver and Windows Vista Sky are not only completely illegal reproductions of pirated copies of Vista but they often have terrible bugs and security deficiencies that can sacrifice the integrity of your data. Honestly, if you're already shooting yourself in the foot with this bootlegged operating system, just get Linux, it's just like stealing but without the unsavory prison shower encounters.

  • Updated JAR files problem

    Hey guys, I just updated my jar files from myfaces-api.jar to myfaces-api1.1.5.jar or something like that. Then all of a sudden my submit function does not work. It keeps having a javascript error...
    form has no properties
    oamSetHiddenInput("linkDummyForm", "autoScroll", "0,0")adminHome.jsf (line 91)
    oamSubmitForm("linkDummyForm", "adminMenu:_idJsp1", undefined, undefined)adminHome.jsf (line 128)
    onclick(click clientX=0, clientY=0)
    ack! i have no idea what im supposed to do! thanks in advance!
    -Arch_Bytes

    The MyFaces user mailing list might get you better results than this forum.

  • Jar file problem

    Hi I am writing a program to query a mySQL database. The program works fine when i run it through netbeans but when i run it by double clicking the Jar file, it gives this error Java.Lang.ClassNotFoundException:com.mysql.jdbc.Driver

    nadeesha wrote:
    Hi I am writing a program to query a mySQL database. The program works fine when i run it through netbeans but when i run it by double clicking the Jar file, it gives this error Java.Lang.ClassNotFoundException:com.mysql.jdbc.DriverYou don't have a JDBC driver for mySQL loaded on your box in a place that is visible on your path. NetBeans is using something, but your system cannot see it.

  • Static variables and JAR files problem

    Hello All,
    I am trying to get two applets to communicate.
    Both are held in the same JAR file loaded from the same location. The JAR file also contains a class with some static variables which are used to comunicate between the two applets.
    The applets are on separate frames in the browser and the system works fine when I don't use a JAR file but when I put the class files into a JAR file, each applet has it's own static variables (not very static).
    Can anyone tell me why static variables stop working when the code is loaded from a JAR file.
    Thanks in advance,
    Alastair.

    Ok,
    I've just tried the below setup and I get the following security exception:
    java.security.AccessControlException: access denied (java.util.PropertyPermission java.home read)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at sun.plugin.security.PluginClassLoader.getPermissions(Unknown Source)
    at java.security.SecureClassLoader.getProtectionDomain(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at appSend.init(appSend.java:62)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    I now have one JAR file which contains the two classes.
    appSend.class & appReceive.class
    and a separate details.class file
    The two HTML files are in separate folders but the JAR file is still the same for both.
    Classes\ -> contains the JAR file (myCode.JAR) and details.class
    Sender\ -> contains the HTML file appSender.html (see below for
    Applet tag)
    Receiver\ -> contains the HTML file appReceiver.html (see below for
    Applet tag)
    appSender.html
    <HTML>
    <HEAD>
    </HEAD>
    <BODY BGCOLOR="000000">
    <CENTER>
    <APPLET
    name = "appSender"
    code = "appSend.class"
    archive = "myCode.JAR"
    codebase = "../Classes"
    width = "500"
    height = "300"
    >
    </APPLET>
    </CENTER>
    </BODY>
    </HTML>
    appReceiver.html
    <HTML>
    <HEAD>
    </HEAD>
    <BODY BGCOLOR="000000">
    <CENTER>
    <APPLET
    name = "appReceiver"
    code = "appReceive.class"
    archive = "myCode.JAR"
    codebase = "../Classes"
    width = "500"
    height = "300"
    >
    </APPLET>
    </CENTER>
    </BODY>
    </HTML>
    Is this how it should be? or have I made a mistake with the tags?
    Can the ClassLoaders in either applet see the details.class file through the codebase tag?
    I'm guessing from the security exception that the ClassLoader for each applet can only load classes from within the JAR file? and can't just use the codebase tag, which is not very helpful!
    Thanks for your help so far.
    Regards,
    Alastair.

  • The Java JAR file "minecraft.jar" could not be launched.

    I just downloaded a new version of this game called Minecraft and it says: The Java JAR file "minecraft.jara" could not be launched. Check the console for possible error messages. I have checked the Console and it says: 
    15/10/2011 23:11:08 [0x0-0x1d01d].com.apple.JarLauncher[191] Failed to load Main-Class manifest attribute from
    15/10/2011 23:11:08 [0x0-0x1d01d].com.apple.JarLauncher[191] /Users/sabi1110/Desktop/minecraft.jar/minecraft.jar
    Help?

    How to Diagnose Jar File Problems
    Open Applications > Utilities > Terminal.app, and then type in the following:
    java -version
    java -jar <drag the minecraft.jar file here>
    Then press Enter. Copy and paste whatever error message appears.

  • Problem with HelpSet in a jar file

    In our application, the content of the html-pages of the help
    set is not displayed ( the index is ! ) if we put the help set
    in a jar file.
    Withour using a jar file, it works fine.
    The problem appeared with all JavaHelp versions I tried (up to 2.0 beta)
    and using JREs >= 1.3.1_0x. Its funny that it works fine with 1.3.1
    Capitels in the file names are NOT the problem.
    Can anybody help me ?
    Do I have to include somethingh in the MANIFEST.MF file of
    the jar ? If so, what ?

    Check the case of the file names such as map.jhm File names are not case sensitive when in a jar file.

  • Problem deploying connector: META-INF/ejb-jar.xml not found in jar file

              Has anyone seen this problem:
              I built Sun's Blackbox implementation and packaged
              it identical to the BlackBoxNoTx.rar included with
              Weblogic's 'jconnector' sample (even using the same
              ra.xml and weblogic-ra.xml). When I try to deploy
              it, the server reports:
              java.io.FileNotFoundException:
              META-INF/ejb-jar.xml not found in jar file
              I have no idea why the server thinks my connector
              is an EJB. If I deploy the BlackBoxNoTx.rar included
              with the sample, everything works without a hitch.
              The only variable that I'm changing in my BlackBoxNoTx.rar
              is that I build the Blackbox classes myself--otherwise,
              the RAR packagings are identical. Any assistance is
              greatly appreciated since I'm banging my head against
              a wall...
              Thanks,
              -jason
              

              I was finally able to resolve this one. On the odd chance that someone else encounters
              the same problem, here's what went wrong:
              My RAR file had two directories: 'META-INF' and 'meta-inf'. The first was created
              by the jar tool and contained the manifest.mf file. The second I created manually
              and it contained my ra.xml and weblogic-ra.xml. When I examined the RAR using
              any tools or I extracted the contents, it looked like it only contained one directory:
              META-INF (because NT is case-insensitive).
              "Jason L" <[email protected]> wrote:
              >
              >Has anyone seen this problem:
              >
              >I built Sun's Blackbox implementation and packaged
              >it identical to the BlackBoxNoTx.rar included with
              >Weblogic's 'jconnector' sample (even using the same
              >ra.xml and weblogic-ra.xml). When I try to deploy
              >it, the server reports:
              >
              >java.io.FileNotFoundException:
              >META-INF/ejb-jar.xml not found in jar file
              >
              >I have no idea why the server thinks my connector
              >is an EJB. If I deploy the BlackBoxNoTx.rar included
              >with the sample, everything works without a hitch.
              >The only variable that I'm changing in my BlackBoxNoTx.rar
              >is that I build the Blackbox classes myself--otherwise,
              >the RAR packagings are identical. Any assistance is
              >greatly appreciated since I'm banging my head against
              >a wall...
              >
              >Thanks,
              >
              >-jason
              

  • Jar file and classpath problem

    I0m writing a program that use the kunststoff.jar Look&Feel.
    Now I would like to put all I'm writing into a jar file but I always have a NoClassFoundException when I try to start my application.
    here is a MANIFEST:ME I'm using:
    Manifest-Version: 1.0
    Created-By: 1.4.2-beta (Sun Microsystems Inc.)
    Main-Class: JListaR.JListaR
    Class-Path: kunststoff.jar img\ .why this don't work?

    Unfortunately you can't embed jars within a jar and
    expect them to be referencable for the classpath from
    outside the main jar. The "Class-Path" attribute in
    the manifest is used to refer to other jar files
    outside of your jar file.
    The usual approach to solve this problem is to unpack
    the jar files you want to embed and then rejar
    everything together in one big jar file again. This
    isn't always a great approach though, I know I'm
    looking for an alternative. So far my only alternative
    is dynamic class loading using a classloader, however
    this isn't great if you need to refer to several
    hundreds or even thousands of classes.thank you very mach...now I understand because it dosen't work correctly!

  • I believe I have a problem with my Jar file build.

    Hi, there. New to Java/JavaFX. Testing language features. Operating System: Windows 7; java version 1.7.0_03; javafx version 2.0.3.
    This is a simple test with 2 classes: Test1.class resides in base directory "MyJavaFX"; TextFileLoader.class resides in sub-directory "inout" of "MyJavaFX"(i.e. MyJavaFX\inout).
    Test1.class has an import statement "import inout.TextFileLoader;" TextFileLoader.class has a package statement "package inout;"
    Both classes compile without problems and jar file is created using Ant tasks.
    Within "MyJavaFX" as my current directory, When running Application Test1 (java -jar Test1.jar)
    getting error "ClassNotFoundException: inout.TextFileLoader".
    I believe it has to do with how Test1.jar file is built. I believe line 4 should say "inout/TextFileLoader.class"
    instead of just the simple class name but I can't get my Ant task to set it up that way.
    This is "Test1.jar":
    META-INF/
    META-INF/MANIFEST.MF
    Test1.class
    TextFileLoader.class
    com/
    com/javafx/
    com/javafx/main/
    com/javafx/main/Main$1.class
    com/javafx/main/Main.class
    com/javafx/main/NoJavaFXFallback.class
    This is my "build.xml" file:
    <project name="JavaFxTest" default="default" basedir="."
         xmlns:fx="javafx:com.sun.javafx.tools.ant">
    <target name="default">
         <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
         uri="javafx:com.sun.javafx.tools.ant"
         classpath="C:/Program Files/Oracle/JavaFX 2.0 SDK/tools/ant-javafx.jar"/>
         <fx:application id="Test1"
         name="Java Test Program"
         mainclass="Test1"/>
         <fx:resources id="appRes">
         <fx:fileset dir="C:/Program Files/Oracle/JavaFX 2.0 Runtime/lib"/>
         </fx:resources>
         <fx:jar destfile="C:/MyjavaFX/Test1.jar">
         <fx:application refid="Test1"/>
         <fx:resources refid="appRes"/>
         <fileset dir="." includes="Test1.class"/>
         <fileset dir="inout" includes="TextFileLoader.class"/>
         </fx:jar>
    </target>
    </project>

    if javaw fails to launch the VM then a dialog should be displayed with an error. The first time I launch an application with javaw (after installing the JVM on a new machine it takes a long time for it to happen. have you tried from the command line >javaw -jar D.jar? I'm wondering if the installation of java went well on your machine. It's supposed to set up things correctly. did you install a new version of java over an existing one? maybe there was a java plugin previously installed on the machine before you installed j2sdk.
    walker

  • Problem in Creating a jar file using java.util.jar and deploying in jboss 4

    Dear Techies,
    I am facing this peculiar problem. I am creating a jar file programmatically using java.util.jar api. The jar file is created but Jboss AS is unable to deploy this jar file. I have also tested that my created jar file contains the same files. When I create a jar file from the command using jar -cvf command, Jboss is able to deploy. I am sending the code , please review it and let me know the problem. I badly require your help. I am unable to proceeed in this regard. Please help me.
    package com.rrs.corona.solutionsacceleratorstudio.solutionadapter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.jar.JarEntry;
    import java.util.jar.JarOutputStream;
    import java.util.jar.Manifest;
    import com.rrs.corona.solutionsacceleratorstudio.SASConstants;
    * @author Piku Mishra
    public class JarCreation
         * File object
         File file;
         * JarOutputStream object to create a jar file
         JarOutputStream jarOutput ;
         * File of the generated jar file
         String jarFileName = "rrs.jar";
         *To create a Manifest.mf file
         Manifest manifest = null;
         //Attributes atr = null;
         * Default Constructor to specify the path and
         * name of the jar file
         * @param destnPath of type String denoting the path of the generated jar file
         public JarCreation(String destnPath)
         {//This constructor initializes the destination path and file name of the jar file
              try
                   manifest = new Manifest();
                   jarOutput = new JarOutputStream(new FileOutputStream(destnPath+"/"+jarFileName),manifest);
              catch(Exception e)
                   e.printStackTrace();
         public JarCreation()
         * This method is used to obtain the list of files present in a
         * directory
         * @param path of type String specifying the path of directory containing the files
         * @return the list of files from a particular directory
         public File[] getFiles(String path)
         {//This method is used to obtain the list of files in a directory
              try
                   file = new File(path);
              catch(Exception e)
                   e.printStackTrace();
              return file.listFiles();
         * This method is used to create a jar file from a directory
         * @param path of type String specifying the directory to make jar
         public void createJar(String path)
         {//This method is used to create a jar file from
              // a directory. If the directory contains several nested directory
              //it will work.
              try
                   byte[] buff = new byte[2048];
                   File[] fileList = getFiles(path);
                   for(int i=0;i<fileList.length;i++)
                        if(fileList.isDirectory())
                             createJar(fileList[i].getAbsolutePath());//Recusive method to get the files
                        else
                             FileInputStream fin = new FileInputStream(fileList[i]);
                             String temp = fileList[i].getAbsolutePath();
                             String subTemp = temp.substring(temp.indexOf("bin")+4,temp.length());
    //                         System.out.println( subTemp+":"+fin.getChannel().size());
                             jarOutput.putNextEntry(new JarEntry(subTemp));
                             int len ;
                             while((len=fin.read(buff))>0)
                                  jarOutput.write(buff,0,len);
                             fin.close();
              catch( Exception e )
                   e.printStackTrace();
         * Method used to close the object for JarOutputStream
         public void close()
         {//This method is used to close the
              //JarOutputStream
              try
                   jarOutput.flush();
                   jarOutput.close();
              catch(Exception e)
                   e.printStackTrace();
         public static void main( String[] args )
              JarCreation jarCreate = new JarCreation("destnation path where jar file will be created /");
              jarCreate.createJar("put your source directory");
              jarCreate.close();

    Hi,
    I have gone through your code and the problem is that when you create jar it takes a complete path address (which is called using getAbsolutePath ) (when you extract you see the path; C:\..\...\..\ )
    You need to truncate this complete path and take only the path address where your files are stored and the problem must be solved.

Maybe you are looking for