Jar Files in a Jar File - Classpath Error

Hi,
I created a jar file that will have all the class files of the application. In the manifest file class path, I have the jar files the application is dependent on. The dependent jar files were kept outside of the application jar file. I was able to execute the main file in the application jar file. Then I created another jar file that holds all the dependent jar files the application is dependent on along with the application jar file into one super jar file. configured the main class attribute of the super jar file to that in the application jar file. When I try to execute it, I'm getting an error saying Class Not Found. Can someone guide me in setting the classpath for this super jar file in its manifest file.
Presently my manifest file classpath variable in the super jar file is set as App.jar Depend1.jar Depend2.jar
Thanks,
E H

Java's standard class loaders do not support jar files inside of other jar files, and will give the error you see.
You can write your own customized class loader, use a 3rd-party solution (onejar at sourceforge is one), or remove the interior jars.

Similar Messages

  • Error while using .jar file instead of class file.

    Hello friends,
    I created a java class which are referred and called from other jsp\xml and java files. I compiled this java class and everything is working properly. However, I do not want to use class files but want to use jar files instead. So, I created a jar file of this class file by using the command "jar -cvf jarfilename.jar".I kept the jar file in its respective folder .Also, I removed the class file from its path, just to see that the jar file will work automatically.
    Unfortunately, I am getting an error:
    java.lang.RuntimeException: Component.createComponent(...) Component class not found: <java class path>. I also tried giving the path of this jar file in the classpath. This also does not seem working.
    How to solve this problem?
    Thanks,
    Ranjith M.V
    Edited by: RanjithM.V on May 11, 2008 10:34 PM

    You probably populated the jar file incorrectly.
    A common mistake is to include the path that you had on the classpath, in the jar file.
    So a person will have a classpath like this: /foo/
    And a class in a package bar, like this:
    package bar;So that other classes would include the file like this:
    import bar.TheClass;And the class file is on the filesystem like this:
    .../foo/bar/TheClass.classThen they'll create the jar file including the foo directory, so if they list the jar's contents, they'll see the above (/foo/bar/TheClass.class). But this is wrong. It should start off so that the jar entries start with the top-level package names (like /bar/TheClass.class).
    Maybe you've done that.

  • Jar files to add to the classpath for KM development.

    Hello Friends:
    I am trying to retrieve the favorites of the user stored
    under him home folder. In KM we have a readymade iview,
    called 'Favorites'. I am programmatically trying to
    read the values stored by this iview.
    I am using NWDS 2.0.5 on EP60SP2Patch3. When I use the
    following code,
    IUserManagementService umService = 
    (IUserManagementService) request.getService(IUserManagementService.KEY);
    // get the user object
      IUser user =
    umService.getDefaultFactory().getUser(userId);
    IResourceContext context =   new ResourceContext(user);
    in my IDE I get the following error:
    "This compilation unit indirectly references a missing
    type com.sapportals.portal.security.usermanagement.
    IUserFactory"
    The following are the jar files added to my project's
    classpath.
    com.sap.portal.usermanagementapi.jar
    com.sap.portal.usermanagementcore.jar
    com.sap.portal.usermappingapi.jar
    com.sap.security.api.jar
    com.sap.security.api.perm.jar
    com.sap.security.core.jar
    com.sap.security.core.tpd.jar
    apart from the usual portal framework related jar files.
    I tried also to add all the jar files with the prefix like...
    com.sap.km.*
    com.sap.netweaver.bc.*
    It didn't help.
    What are the other jar files I need to add, and where
    they are available.
    BTW, I unzipped all the 'portallibs' downloaded from the
    portal and using those jar files to attach to the project.
    Thank you very much,
    Prasad Nutalapati

    Hi Prasad,
    additionally you need com.sap.security.api.ep5.jar due to the fact that KM is using the old EP5 usermanagement libraries.
    Concerning the KM / RF libraries I would recommand to include all libraries matching the patterns bc._api.jar and km._api.jar
    Best regards,
    Thilo

  • How to add a jar file in the visual Age classpath

    I have to import a jar file in visual Age workspace, and don't know hox to do
    I tried several things, but didn't succeded at this point.
    I need to succed until tomorrow for completing my work.
    Please help, thanks.

    Pls do the foll actions:
    Step 1:
    File -> Import -> Selct radiobutton - "Jar file" -> Next
    -> Select the file name(ur jar file) - > click on the java button and ensure that u have selected all the file or what evre files u want " -> Finish
    If at all u r not getting any errors but the files are not apperaring in ur Project means go to
    Step 2:
    From the work bench click
    Window -> Reposiroy Explorer -> Select the Project,edition,package or type and right click and from the pop up menu click "Add to Workspace"
    This 'd work
    All the best for a successful completion of ur work
    Pramod

  • I cannot complete an installation of ITunes.  During the install, I receive the following error message:   Error writing to file: C:\Program Files\Bonjour\dns_sd.jar.

    I cannot complete an installation of ITunes.  During the install, I receive the following error message:
    Error writing to file: C:\Program Files\Bonjour\dns_sd.jar.

    That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
    XP instructions in the following document: How to perform disk error checking in Windows XP
    Vista instructions in the following document: Check your hard disk for errors
    Windows 7 instructions in the following document: How to use CHKDSK (Check Disk)
    Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
    Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards?

  • Error writing to file: C:\Program Files\Bonjour\dns_sd.jar.

    I cannot complete an installation of ITunes.  During the install, I receive the following error message:
    Error writing to file: C:\Program Files\Bonjour\dns_sd.jar.

    That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
    XP instructions in the following document: How to perform disk error checking in Windows XP
    Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
    Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards?

  • JAR file updating project config file error. Help needed!

    Hi all,
    I got a problem when I want to use an existed jar file. There is a method called setConfig which can read and update the properties inside a property file which will be located inside the deployed jar file. But when the other project want to use this jar file. It causes the following error:
    Property 'configfile' threw exception; nested exception is java.lang.IllegalArgumentException: URI is not hierarchical
    The code might cause this error is like:
    String temp = configfile.substring(CLASSPATH_IND.length()).trim();
    URL url = BaseConfigureFactory.class.getClassLoader().getResource(temp);
    try {
    tempcfg = (new File(url.toURI())).getAbsolutePath();
    } catch(URISyntaxException use) {
    throw new IllegalArgumentException(use);
    It seems like the url is wrong so that the program can not find the configfile. Does anyone give some suggestions? Thanks

    I have all of e.printStackTrack( ) in my try - catch block. But i also think the blank screen appears because the class can not find my resources. Maybe it's my fault, because i create by hand a folder name "res" in project folder, then put all my resource in this folder. And in Eclipse when i try to get these resource, i wrote something like this:
         Image robot1N, robot1E, robot1S, robot1W;
         private void initResources() {               
              try {               
                   String sb = "car1";
                   robot1N = ImageIO.read(new File("res\\img\\unit\\" + sb +"_N.png"));
                   robot1E = ImageIO.read(new File("res\\img\\unit\\" + sb +"_E.png"));
                   robot1S = ImageIO.read(new File("res\\img\\unit\\" + sb +"_S.png"));
                   robot1W = ImageIO.read(new File("res\\img\\unit\\" + sb +"_W.png"));
              catch(Exception e) {
                   e.printStackTrace();
         }Maybe the string of path to resource is right in Eclipse but wrong in Window?

  • How to run class files in a jar independently.

    Hello all
    I have a java file which use an API.jar file which is an API file of some other application of mine.This file form a sought of client for that application.Now i want to run this file from command line which is giving NoClassDefFoundError exception.This exception is because of the dependency over API.jar.I dont want to pack this single file into a jar and then run that jar since it only makes a simple task complicated and makes a simple class look like a big application.Can anybody tell me the solution to it?
    Regards,
    Mansi

    MansiSachar wrote:
    I am working on WindowsXP and the command u just sent is again giving the same exception.The exception is :
    Exception in thread "main" java.lang.NoClassDefFoundError: ûcp
    Caused by: java.lang.ClassNotFoundException: ûcp
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    I think the problem can also be the placement of the dependant jars.do i need to keep them in "bin" folder?I am assuming that in the error message, it says "-cp" not "ûcp" Can you confirm that you entered the command as posted? Because it looks like java.exe sees the -cp as the class to execute instead of the classpath option.
    Try using -classpath instead of -cp. What version of java are you using? (java -version should give you the version).
    If the jars are in the current directory, the placement of the jar files is correct.

  • Accessing a Jar file within my jar...

    Hi,
    I've got a JDBC Jar file that I wish to include in my Jar package, but I'm unsure how to do this...
    I'm using ant to compile my code & package it up into the Jar, & I can get it to compile fine, and package everything up fine (including the JDBC jar), but when I go to run the app I get an error
    (No suitable driver).
    My app works fine without being Jar'ed up.
    I'm guessing that I need to set the classpath to reference the JDBC jar file in my jar... but I'm unsure how to do this.
    Any help would be greatly appreciated.

    package what you thirdpart jar file and your jar file to one jar file..
    it will run ok.
    maybe the below tool can help you.
    a tool named JavaJar(written by java) can compress and decompress jar,war, ear and.zip...
    may download from http://www.qwerks.com/download/4114/JavaJar.zip
    the tool is very verygood tool.
    but the homepage(www.pivotonic.com) of JavaJar cannot be accessed.
    it is funny.
    good lucky.

  • ANT - Jar File include another Jar file and importing classes

    Here is the directory structure i have set up:
    FTPGetter
      \src
        \com
          \abc
            \ftpgetter
              - GUI.java
              - FTPGetter.java
              - Login.java
      \classes
      \include
        - ftpClient.jar
        - info.xml
      \jar
        - FTPGetter.jarThe code compiles file and can create a Jar file without errors. But when I execute the Jar file, I get
    java.lang.NoClassDefFoundError: com/abc/ftpclient/FTPwhich is a class that I import from the ftpClient.jar file in FTPGetter.java
    What gives?
    Here is my necessary build.xml code:
    <?xml version="1.0"?>
    <project name="FTPGetter" default="all">
      <property name="src.dir"        value="src"/>
      <property name="package.name"   value="com.abc.ftpgetter"/>
      <property name="package.dir"    value="${src.dir}/com/abc/ftpgetter"/>
      <property name="classes.dir"    value="classes"/>
      <property name="include.dir"    value="include"/>
      <property name="jar.dir"        value="jar"/>
      <property name="javadoc.dir"    value="docs"/>
      <property name="javadoc.title"  value="FTPGetter"/>
      <property name="javadoc.header" value="FTPGetter - By ABC XYZ [2005]"/>
      <property name="run.classname"  value="${package.name}.FTPGetter"/>
      <target name="init">
        <mkdir dir="${javadoc.dir}" />
        <mkdir dir="${classes.dir}" />
        <mkdir dir="${jar.dir}" />
      </target>
      <target name="all" depends ="compile,jar" />
      <target name="compile" description="Compile Java code" depends="clean, init">
        <javac srcdir="${package.dir}" destdir="${classes.dir}">
          <classpath>
            <!-- use the value of the ${classes.dir} property in the classpath -->
            <pathelement path="${classes.dir}" />
            <!-- include all jar files  -->
            <fileset dir="${include.dir}">
              <include name="**/*.jar"/>
            </fileset>
          </classpath>
        </javac>
      </target>
      <target name="clean" description="Clean up">
        <delete dir="${javadoc.dir}" />
        <delete dir="${classes.dir}" />
        <delete dir="${jar.dir}" />
      </target>
      <target name="jar" depends="compile">
        <jar jarfile="${jar.dir}/FTPGetter.jar" update="false">
          <fileset dir="${classes.dir}" includes="**/*.class" />
    <!-- Include xml file to read.-->
          <fileset dir="${include.dir}" includes="info.xml" />
    <!-- Include ftpClient in the jar file.-->
          <fileset dir="${include.dir}" includes="ftpClient.jar" />
          <manifest>
            <attribute name="Main-Class" value="com.abc.ftpgetter.FTPGetter" />
            <attribute name="Class-Path" value="include/ftpClient.jar"/>
          </manifest>
        </jar>
      </target>
    </project>

    nevermind I got that fixed now:
    had to get the build.xml code for the <target name="jar" depends="compile">so that it looks more like:
      <target name="jar" depends="compile">
        <jar jarfile="${jar.dir}/FTPGetter.jar">
          <zipfileset dir="classes" prefix="" />
          <zipfileset src="include/ftpClient.jar" />
          <zipfileset dir="${include.dir}" includes="info.xml" />
          <manifest>
            <attribute name="Main-Class" value="com.abc.ftpgetter.FTPGetter" />
          </manifest>
        </jar>
      </target>Keyword would need to be zipfileset.

  • Can Netbeans put a jar file In a jar file?

    I just went through the process of getting Eclipse to create a jar file that would execute from a command prompt using a plugin called fatjar :
    http://fjep.sourceforge.net/
    Details from other thread :http://forum.java.sun.com/thread.jspa?threadID=5219638&tstart=0
    I really would like to use netbeans but i now have the exact same problem trying to make a jar file in netbeans 5.5.1
    I am using a package from icaste.com It has a
    .dll file to put in the windows directory
    JCommSerial_3_0.jar file that contains all the classes
    I can compile and run a file in the IDE and it works fine
    The Jar file does not contain the classes so i get errors when running from command line.
    Here is the layout of my screen and result of run command in IDE
    http://www.acousticlights.com/netbeans.png
    What do I need to try?

    georgemc wrote:
    Why is everyone so obsessed with doing this? The gains are minimal and the problems numerousBecause we are new and don't understand how the java VM actually runs code and the error messages sent by the java machine are cryptic.
    My first attempt at using an external jar in a java program lead me to believe that all of the code for a java program would be in a jar file including external jar files, after all the JDK standard library has tons of jars in it so I assumed the external jar file would be linked (as most other programming compiler/linkers I have worked with in my top down programming life).
    I find out the answer is so simple that the external jar file could not be found by the VM running my jar file. Like I said, if the VM would have just gave me an error that it could not find a file on a specific directory i never would have perused the idea of jar in a jar (fatjar plugin for Eclipse for example)
    Really this is like getting into a race car and not knowing at what RPM to shift gears, sure you can press the pedal and make it go but if you don't understand how it works under the hood you are going to blow the engine if you keep it in first gear.
    I have read many posts on these errors, the reason is the error message is just not very descriptive of the original problem. If I try and open a database called xyz.dbf that has one field defined as lastname, in C for example, I would not give the error message "Lastname could not be found) when indeed the lastname could not be found but the reason it could not be found was because the database xyz.dbf could not be found. Further , adding to the error message that the system is looking for xyz.dbf on drive X- subdirectory -mydatabases would complete the error message and allow the user to fix the error. Just what is a non java programmer that is using my java program suppose to do with an Ecception Error in (main) bla bla bla... I know now I need to check for library files myself within my own java programs and give a better error message to the user before the java VM sends out it's cryptic message.
    Edited by: metron9 on Sep 25, 2007 11:00 AM

  • How do I read a text file in a Jar Executable?

    Hello All,
    I have a need to package a text file into a Jar Exectable file and then have my java code read that text file in using a BufferedReader. Can anyone out there tell me how to do this? My first question is how do I reference this file by the path name? O, I'm also using Windows.
    Thanks for your help.
    Karl

    I have the same problem with kportner . I did by joop_eggen but I got the error at:
    BufferedReader in = new InputStreamReader(is);Can't conver from BufferedReader to InputStreamReader
    When I up my applet to server and get it from client. My applet couldn't read the text file.
    Any one help me!
    Thanks.

  • How can  I access my java class file in a .jar file ...PLz Help anyone!!

    Hi Folks,
    I am new in Java programming, have a .jar file that contains .java files that I want no access and use from another .java file. These files in the .jar file basically form a library thus have no main-method. However I can not declare an instance of the library (in the .jar file) and use it within my program.
    Plz help ...I have tried all I know in vain.
    Thanks.

    temba wrote:
    Hi Folks,
    I am new in Java programming, have a .jar file that contains .java files that I want no access and use from another .java file. These files in the .jar file basically form a library thus have no main-method. However I can not declare an instance of the library (in the .jar file) and use it within my program. You are making little sense. You can't instantiate .java files.
    Plz help ...I have tried all I know in vain.
    Thanks.Could you post WHAT you have tried and also post what error messages you received?

  • Creating a JAR in Eclipse...can't access files in the JAR properly.

    Hi all! I'm a newbie at JAR creation, and am having troubles. I have a project that loads images from image files in my project. I can create the JAR and all, and it runs, but the buttons that have ImageIcons with those IO loaded images are blank. I've tried to include the images when creating the JAR, but it keeps acting like the images never existed. When I run the JAR and have the images separately included in the directory (instead of packing them up too), it won't work as well...UNLESS those images are put in my $HOME directory (Linux).
    Does anyone know how I can properly refer to the images that I'm trying to pack into the JAR from within the JAR? Or, is there a way for the JAR to understand where those images are supposed to be (redirect the focus from the $HOME directory to the JAR's directory)? Any help would be greatly appreciated! :)
    -Keith

    Hi,
    Can the user execute the program through explorer? In Windows Server 2003, the Users group does not have Read and Execute permissions to the command processor (Cmd.exe). 
    You could refer to the article below to resolve the issue:
    "Access is denied" error message when you run a batch job on a Windows Server 2003-based computer
    http://support.microsoft.com/kb/867466
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Packages in separate Jars causes classpath error

    For the purposes of easy-updating and allowing developers to work on one part of a system without interfering with others, I have created separate Jar files for the main packages in my application. So;
    com.me.pack1 is in Pack1.jar
    com.me.pack2 is in Pack2.jar
    An ant build takes care of building and packaging these up. The Jar files have the correct directory structure i.e.;
    jar $ $JAVA_HOME/bin/jar tf /users/jmcparla/jar/Pack1.jar
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/me/
    com/me/pack1/
    com/me/pack1/MainClass.class
    jar $ $JAVA_HOME/bin/jar tf /users/jmcparla/jar/Pack2.jar
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/me/
    com/me/pack2/
    com/me/pack2/OtherClass.classHowever when I run it;
    jar $ $JAVA_HOME/bin/java -cp /users/jmcparla/jar/Pack2.jar -jar /users/jmcparla/jar/Pack1.jar
    Entered main
    Created MainClass instance
    Exception in thread "main" java.lang.NoClassDefFoundError: com/me/pack2/OtherClass
            at com.me.pack1.MainClass.main(MainClass.java:13)The classes are;
    MainClass.java
    package com.me.pack1;
    import com.me.pack2.OtherClass;
    public class MainClass
        public static void main(String[] args)
            System.out.println("Entered main");
            new MainClass();
            System.out.println("Created MainClass instance");
            new OtherClass();
            System.out.println("Created OtherClass instance");
    }OtherClass.java
    package com.me.pack2;
    public class OtherClass
    }and the build file is;
    build.xml
    <project name="JarProblem" default="buildJars" basedir=".">
      <property name="classdir" value="classes"/>
      <target name="compile" depends="clean" description="compile the code">
          <mkdir dir="${classdir}"/>
          <javac debug="on" debuglevel="vars,lines,source" srcdir="."
                 destdir="${classdir}" encoding="ISO-8859-1">
          </javac>
      </target>
      <target name="buildJars" depends="compile" description="build the jar files">
        <antcall target="buildPack2"/>
        <antcall target="buildPack1"/>
      </target>
      <target name="buildPack2" description="build the Pack2 jar">
        <tstamp>
          <format property="time" pattern="hh:mm aa dd/MM/yyyy"/>
        </tstamp>
        <jar destfile="Pack2.jar" update="false">
          <fileset dir="${classdir}">
            <!-- Only include the package we're building -->
            <include name="com/me/pack2/*"/>
          </fileset>
          <manifest>
            <attribute name="Built" value="${time}"/>
          </manifest>
        </jar>
      </target>
       <target name="buildPack1" description="build the Pack1 jar">
        <tstamp>
          <format property="time" pattern="hh:mm aa dd/MM/yyyy"/>
        </tstamp>
        <jar destfile="Pack1.jar" update="false">
          <fileset dir="${classdir}">
            <!-- Only include the package we're building -->
            <include name="com/me/pack1/*"/>
          </fileset>
          <manifest>
            <attribute name="Main-Class" value="com.me.pack1.MainClass"/>
            <attribute name="Built" value="${time}"/>
          </manifest>
        </jar>
      </target>
      <target name="clean" description="clean up the compiled source files">
        <delete verbose="false" failonerror="false">
          <fileset dir="${classdir}"/>
        </delete>
      </target>
    </project>The build completes with no problems. So why can't the java command see OtherClass?

    johnmcparlald wrote:
    However when I run it;
    jar $ $JAVA_HOME/bin/java -cp /users/jmcparla/jar/Pack2.jar -jar /users/jmcparla/jar/Pack1.jar
    Entered main
    Created MainClass instance
    Exception in thread "main" java.lang.NoClassDefFoundError: com/me/pack2/OtherClass
    at com.me.pack1.MainClass.main(MainClass.java:13)
    I can't help you with ant but I can tell you that the command you entered looks wrong. If you use the -jar option with the java command, the only classpath that is used is the one specified by the Class-Path entry in the manifest - other classpaths are ignored.
    So you either need to leave off the -jar, include the Pack1.jar file and specify the main class, or include the Class-Path: Pack2.jar entry in the manifest. (At least, it looks to me like there is no Class-Path in the manifest.)

Maybe you are looking for

  • Pricing problem with value based free goods!

    Hi All, I've got a pricing problem..... Can anyone can come out with a solution. Here is the Business Scenario.... In a super market pricing...should be implemented in such a way that....if the customer purchases any material(all materials) for $1000

  • Assigning Full Folder In DMS

    Dear Sir/mam In CV01N insteat of assigning single file i want to assign full folder with many autocad files, can you sugest any other subsequent way to assign so many file bcoz every time i have to select sing file. I hadassigned one document to doc.

  • PSE 9 Editor Screen Font Too Small

    I just upgraded to PSE 9 when I purchased a new PC and High Def monitor set at the recommended resolution of 1920x1080. Now the font in the Editor is so small I cannot read it. Changing the monitor DPI does not change the Editor font. Is there a way

  • OK I am new with Icloud.  I have an Iphone 4s.  I would like to be sure my phone is downloading to Icloud.  How can i be sure?

    How do I connect to Icould to be sure it is downloading my info from my Iphone 4S (Obvisouly I am new with this phone).

  • Macbook wakes up from sleep mode on its own

    Hey, bought my 13 inch unibody mb last year and it has always been working properly. However, as soon as I installed Snow Leopard, a strange thing occurs which has already almost killed my mb by overheating... When I close my mb, it turns to sleep mo