Class-Path assistance needed in Jars

I'm having trouble with my Jar files. I have all the classes associated w/ the project in jar files in a lib directed. I then jar that directory w/ the main class file along with some extra directories (images etc). When I run the jar file created using the -jar switch...it states that it can't find a file that is inside the jar file itself. It will work if I have the directories and the files un-jar'ed in the same directory as the jar however I'm hoping that I dont' have to do that.
Below is my manifest file:
Main-Class: btCommander
Class-Path: lib\namespace.jar lib\relaxngDatatype.jar lib\jaxb-libs.jar lib\jaxb-api.jar lib\jaxb-impl.jar lib\classbox.jar
(i do have a carriage return after the last jar file in classpath).
When i jar the files (using either Ant or jar.exe) it packs the files however it doesn't allow me to execute the jar alone.
Any help will be appreciated.
Llama

If I understand your problem correctly, the reason is because jar files cannot contain other jar files. Well they can but you won't be able to load any classes from them.

Similar Messages

  • Class-Path assistance needed for jars

    I'm having trouble with my Jar files. I have all the classes associated w/ the project in jar files in a lib directed. I then jar that directory w/ the main class file along with some extra directories (images etc). When I run the jar file created using the -jar switch...it states that it can't find a file that is inside the jar file itself. It will work if I have the directories and the files un-jar'ed in the same directory as the jar however I'm hoping that I dont' have to do that.
    Below is my manifest file:
    Main-Class: btCommander
    Class-Path: lib\namespace.jar lib\relaxngDatatype.jar lib\jaxb-libs.jar lib\jaxb-api.jar lib\jaxb-impl.jar lib\classbox.jar
    (i do have a carriage return after the last jar file in classpath).
    When i jar the files (using either Ant or jar.exe) it packs the files however it doesn't allow me to execute the jar alone.
    Any help will be appreciated.
    Llama

    http://forum.java.sun.com/thread.jsp?forum=22&thread=405160&tstart=0&trange=100

  • Java 5.0 does not recognize wrapped Class-Path in Manifest.MF of .jar file?

    Java: build 1.5.0_05-b05
    Ant: 1.6.2
    I use Ant <jar> task to create a standalone application in a .jar file. I have a very long "Class-Path" in the Manifest.MF file. The long Class-Path is wrapped at every 70th character by the <jar> task. I cannot run "java -jar <the jar file>", because Java runtime cannot find classes.
    I found the following Q&A from ANT's FAQ page,
    Q: Whenever I use the Ant jar or manifest related tasks, long lines in my manifest are wrapped at 70 characters and the resulting jar does not work in my application server. Why does Ant do this?
    A: Ant implements the Java Jar file specification. Please refer to the notes section where it discusses the maximum allowable length of a line and the concept of continuation characters.
    If a jar file produced by Ant does not work in your appserver, and that failure is due to the wrapped manifest, then you need to consult your appserver provider, as it is a bug in their appserver. Far more likely, however, is a problem in your specification of your classpath. It is not Ant's wrapping of your classpath that is the problem.
    Do not raise a bug about this issue until you have checked to ensure that the problem is not due to your classpath specification.
    Any idea?

    "will be searched ALSO."...
    From: http://java.sun.com/docs/books/tutorial/ext/basics/load.html
    Understanding Extension Class Loading
    The extension framework makes use of the new class-loading mechanism in the JavaTM 1.2 platform. When the runtime environment needs to load a new class for an application, it looks for the class in the following locations, in order:
    1. Bootstrap classes: the runtime classes in rt.jar and internationalization classes in i18n.jar.
    2. Installed extensions: classes in JAR files in the lib/ext directory of the JRE.
    3. The class path: classes, including classes in JAR files, on paths specified by the system property java.class.path. If a JAR file on the class path has a manifest with the Class-Path attribute, JAR files specified by the Class-Path attribute will be searched also.
    [snip]

  • Who knows about Jar/Manifest: Class-Path-Attribute

    My question is:
    When packaging my classes and ressource files into a jar file, everything works fine as long as I put the manifest-file into the parent directory of the package folders (there's the main class too) and set its Class-Path-Attribut just as . (a dot).
    I'm working with WinXP Prof.
    As soon as I fill in a path with backslashes or slashes as separator, the produced jar-file doesn't work (class loader does'nt find main-class).
    Is the problem the drive-letter (D:) in the path or do you know something else?
    Greetings
    Frank

    Yes, and likely the . is what you need ...saying: I want the packages which begin in the same directory as the jar running this application. Even if your class is in a package hierarchy like tst.test.Support.class, if the directory tst is in the same directory as the application jar, you would use classpath . not tst/test/Support.class. If you put the tst package in a directory under the folder where the jar resides, say called testit ...you would then have a classpath in the mainifest like testit/. The class path always needs to get you to the root of any package you want to use ...but not into the package itself. Java recognizes when it is looking at a package nesting due to the package declaration syntax in the files, the classpath just points to the location of the root of that package and nothing more. Does this make sense?

  • Jar: Manifest-Attribute "Class-Path"

    I've got a problem with the Class-Path-attribute of the JARs manifest-file. So I've written a real simple application to test where the problems occure... but even this trivial app does not work!
    The execution starts at "Starter.java":
    public class Starter{
          public static void main(String args[]){
                packageOne.Caller.callWriter();
    }The class "Caller" is in a JAR ("Caller.jar") in the same directory as Starter.java.
    Caller.java:
    package packageOne;
    public class Caller{
          public static void callWriter(){
                packageTwo.Writer.write("Write this");
    }The class "Writer" is in a JAR ("Writer.jar") in the same directory as Starter.java and Caller.jar.
    Writer.java:
    package packageTwo;
    public class Writer{
          public static void write(String message){
                System.out.println(message);
    }The file Caller.jar consists of Caller.class and the Manifest.mf. The package-structur/the path seams to be all right.
    The file Writer.jar consists of Writer.class and the Manifest.mf. The package-structur/the path seams to be all right.
    If I invoke the Starter with:
    java Starter -classpath Caller.jar;Writer.jareverything's fine.
    Now, I added the following line to the Manifest.mf of Caller.jar:
    Class-Path: Writer.jar(with one empty line between Manifest-Version: 1.0 and the new line.
    So... shouldn't it be possible now, to invoke the application with:
    java Starter -classpath Caller.jar ???
    It doesn't work. So: what have I misunderstood?
    (The error message is:
    Exception in thread "main" java.lang.NoClassDefFoundError: packageTwo/Writer
          at packageOne.Caller.callWriter(packageOne/Caller.java:5)
          at Starter.main(Starter.java:3)

    Hmmm, I tested it and here are the command I ran and their results. Try doing the same on your computer:aleph% mkdir packageOne
    aleph% mkdir packageTwoThat created the directories.aleph% cat > Starter.java
    public class Starter{
          public static void main(String args[]){
                packageOne.Caller.callWriter();
    aleph% cat > packageOne/Caller.java
    package packageOne;
    public class Caller{
          public static void callWriter(){
                packageTwo.Writer.write("Write this");
    aleph% cat > packageTwo/Writer.java
    package packageTwo;
    public class Writer{
          public static void write(String message){
                System.out.println(message);
    }That created the source files: Starter.java in the current directory, Caller.java under packageOne and Writer.java under packageTwo. Next the compiling and creating the manifest file:aleph% javac Starter.java
    aleph% cat > MF
    Class-Path: Writer.jarThat created additional info to be included in manifest file and put it in a file called MF.
    Then I package "caller.jar" with the manifest and "Writer.jar" without it:aleph% jar -cmf MF caller.jar packageOne
    aleph% jar -cf Writer.jar packageTwoDelete the package* directories so java wont get confused...aleph% rm -r package*And finally run the thing. Remember that the path separator is : in unix but ; in DOS, if that is what you are using.aleph% java -cp .:caller.jar Starter
    Write thisNo problems anywhere. What are the steps you did?

  • Stand alone class and the class path

    Hi,
    I have a simple Java project in Eclipse environment. The project has it's class path,
    that contains a jar file that I need to use.
    The project runs perfect in the Eclipse.
    Now, I need to take the main class out of my project, to function alone in another environment.
    My problem is that out of the environment, I don't know how the class should know that classpath.
    I moved that jar to the same folder that the class located in, but I don't know how to tell it that the jar is there.
    My goal is to run my standalone class from another java class.
    I'm afraid that examples in command environment wouldn't help me.
    Thanks a lot for any help !

    moshi wrote:
    I have a simple Java project in Eclipse environment. The project has it's class path,
    that contains a jar file that I need to use.Ok, so you have a class that you have written that depends on an external library. Fair enough.
    The project runs perfect in the Eclipse.
    Now, I need to take the main class out of my project, to function alone in another environment.Maybe (just maybe!) defining what exactly that "other environment" is could help us help you.
    My problem is that out of the environment, I don't know how the class should know that classpath.Well, obviously that depends on what that other environment is.
    You must have some way to influence that other environments classpath, or you couldn't even get it to call/use your class.
    I moved that jar to the same folder that the class located in, but I don't know how to tell it that the jar is there.Now you're just guessing.
    My goal is to run my standalone class from another java class. That's simple enough, you probably do it all the time.
    I'm afraid that examples in command environment wouldn't help me.And why exactly is that?
    Do you realize that you tell us far too little about your problem for us to be able to actually help you?

  • Class path fully qualified vs offset

    I am invoking a JVM from a c++ application and I am having problems setting a fully qualified classpath. If I set the class path like the following, I get NoClassDefFoundError errors.
    stringstream classPath;
    classPath << "-Djava.class.path=/home/user1/application"
    << ":/home/user1/application/myjar1.jar"
         << ":/home/user1/application/myjar2.jar"
         << ":/home/user1/application/myjar3.jar"
         << ":/home/user1/application/myjar4.jar";
    But, if I set the class path as an offset from the directory in which I launch my application, everything works correctly.
    classPath << "-Djava.class.path=."
    << ":./myjar1.jar"
         << ":./myjar2.jar"
         << ":./myjar3.jar"
         << ":./myjar4.jar";
    The remaining code to set up the JavaVMOptions:
    JavaVMOption options[4];
    options[0].optionString = "-Djava.compiler=NONE";
    options[1].optionString = (char *)(classPath.str().c_str());
    options[2].optionString = "-Djava.library.path=.";
    options[3].optionString = "-Xmx1000m";
    Anyone have any similar problems?

    Actually, what I did is to copy (sprintf) the string
    stream's char * to a local char * variable. Then I
    set the classpath optionString equal to the local char
    *. Seems unecessary but it works.Not sure if that is a good idea but it depends on what you mean by "local char *".
    If you want to do a dynamic classpath then use one of the following..
    1. A global char array with a fixed (big) size.
    2. A global char pointer that you initialize to the size needed.
    With either of the above you can also use the string stream by passing in the array via the constructor.

  • Manifest class-path does not works

    Hi,
    We use Jrockit 1.4.2 (latest) on Solaris.
    We found that manifest class-path does not seems to work, we got classdef not found messages.
    If we change the JVM to sun 1.4.2 that everything works perfectly.
    Manifest:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.5.2
    Created-By: 1.4.1_02-b06 (Sun Microsystems Inc.)
    Implementation-Title: com.clarify.igb.common.ejbserver
    Implementation-Version: 12.5.000
    Implementation-Vendor: Amdocs Inc.
    Specification-Title: ClarifyCRM Business Object Infrastructure
    Specification-Version: 12.5.000
    Specification-Vendor: Amdocs Inc.
    Class-Path: ClfyShared.jar ClfyCbo.jar ClfyClient.jar ClfyWebInf.jar C
    lfyiSupport.jar ClfyUtil.jar jdom.jar ClfyCommon.jar ClfySales.jar Cl
    fymOrder.jar ClfyiAdmin.jar ClfyBilling.jar ClfyBillingManager.jar Cl
    fyEmailProcessor.jar
    What can be the problem?
    Regards.,
    LJ

    Hi Jaejun,
    a.jar should also have a MANIFEST.MF Class-Path refering to b.jar.
    HTH
    Regards,
    Slava Imeshev
    "Jaejun Lee" <[email protected]> wrote in message
    news:3e541ede$[email protected]..
    >
    I meant <CRLF> not <CR> only.
    Thank you.
    "Jaejun Lee" <[email protected]> wrote:
    Ravinder Pal <[email protected]> wrote:
    I have read all message posted in this regard but my problem still
    remain.
    Please read the context to give me some pointers.
    myapp.ear contains
    - myejb.jar contains
    - manifest with Class-Path a.jar b.jar
    - a.jar (Internal)
    - b.jar (Some external Vendor)
    Problem: Call from a.jar classes which reference b.jar classes doesraise
    a ClassNotFoundException.
    Thanks.
    I have a similar problem with WebLogic 7.0 sp1.
    I have to verify this.
    Dose WebLogic support MANIFEST.MF Class-Path in development-mode.
    Indeed, I just put a.jar and b.jar in application directory.
    I put Class-Path: b.jar<carrage-return> in MANIFEST.MF of a.jar.
    But, a.jar cannot find classes in b.jar.
    Do I have to make EAR?

  • Specify Main-Class to /bin folder inside Jar?

    I'd like to set the Main-Class of my runnable jar to use a class inside /bin INSIDE the jar
    this is because one of my packages's first folder is /gl and there is a /gl folder containing resources inside my jar's root dir... want to seperate those.
    Thanks!
    IE:
    Main-Class:bin/package.package.classname
    doesn't work, even if my classes are all inside bin.

    Make two jars, one for code, one for resources. Name the resource jar in the Class-Path of the first jar's manifest.
    The bin trick would not work.

  • Running a Java class which depends on a Jar

    Hi,
    I try to run a class using the command java packagename.classname.
    This class depends on a jar for functioning.
    So, when I run this class, exception related to the absence of this Jar is shown.
    How can I overcome this? Where should I place this jar or running any other commands for loading this jar will do?
    Please help.
    Any help in this regard will be well appreciated with dukes.
    Regards,
    Rony

    Hi Rony,
    Place the that jar file in your class path.
    or
    Place that "jar file path" in Enivronment Variables of your computer under "Class path" variable
    or
    set the class path using command prompt.
    Thanks,
    Sekhar

  • How to run a jar file which needs another jar to be in the class path

    Hi,
    I need to execute a jar, which needs another jar to be in the classpath.
    If I run like
    java -classpath <jar1 name> -jar <main jar>
    It is giving classnotfoundexception, where as the class is available in the <jar1 name>.
    so, currently I am doing like this
    In the manifest file i have given like
    Main-Class: <class name>
    Class-Path: <jar name> <jar name2>
    then it is running fine. But, if I want to change the jar location again I need to changed the manifest file.
    Is there any way to do this? Pls help me.

    How about
    java -cp jar1.jar;jar2.jar com.acme.MainClass
    You won't need to worry about the manifest file after that and you can make a bat files (or .sh file in *nix) for it.                                                                                                                                                                                                                                                                                                                                                                       

  • How do I add the system classpath to Jar Manifest Class-Path

    My application is implemented on win2000 and need to be moved to unix as a executable jar file, the oracle jdbc classes (classes12.zip and classes111.zip) were included in MANIFEST.MF as the following:
    Class-Path: /Oracle/Ora81/jdbc/lib/classes12.zip /Oracle/Ora81/jdbc/lib/classese111.zip
    When I move the jar file to unix, the classpath will be changed, is there a way to make the jar file read the class-path from system CLASSPATH?
    Thank you.
    Y.

    I have the same problem for weeks now, and I can't seem to get it solved. If you found anything please inform me.
    thanks in advance
    Eran

  • Alternate drives in Jar file Class-Path attribute

    Hello, all. I am working on a project that I would like to package into a single jar file for simple execution. At my place of work classes from EJB are stored on a different drive from where I am doing the development. I am having trouble accessing those classes from the Jars I am creating. When I try the following manifest:
    Main-Class: MyPackage.MyClass
    Class-Path: U:\someFolder
    the application will not start, saying that MyPackage.MyClass cannot be found. This is despite MyPackage.MyClass being properly packaged into the Jar file, as verified by a jar t operation. When I leave off the drive letter in the Class-Path attribute:
    Main-Class: MyPackage.MyClass
    Class-Path: someFolder
    the application starts and executes properly right up until a class from someFolder is needed, at which point exceptions begin to be thrown.
    Any ideas will be much appreciated!
    John Todd

    I was eventually able to find the answer to my own question: Jars do not accept absolute paths at all, only relative paths. Thus, the alternate drive approach will not work. Fortunately I was able to find an alternate solution.
    John Todd

  • Jar class path in solaris

    Hi
    I am new to solaris environment. I have a java file which is dependent on xerces.jar. to compile the file i need to set the classpath. pleas let me know how to set class path for xerces.jar which is in usr/raj/ folder structure of solaris machine.
    if there is any on the fly method of setting classpath plz let me know....
    thanks a lot
    raj

    What shell are you using?
    csh:  setenv CLASSPATH ${CLASSPATH}:/usr/raj/xerces.jarsh/ksh:  CLASSPATH=${CLASSPATH}:/usr/raj/xerces.jar
      export CLASSPATH

  • Classloader isolation and jar manifest Class-Path headers

    I have a system where I am loading a set of jars, each with its own URL classloader. So, Jar a is loaded by Loader A, jar b is loaded by Loader B, and so on.
    Each jar has a Manifest Class-Path entry declaring its dependence on other jars. So in the example above, a puts c.jar in its Class-path, and, let's say, b also puts c.jar in its Class-path, unbeknownst to a.
    Let's say there's a class Foo in c.jar. I want--need--it to be the case that (loader of a.jar == Foo.class.getClassLoader()) from the perspective of classes found in a.jar, and (loader of b.jar == Foo.class.getClassLoader()) from the perspective of classes found in b.jar.
    That is, I want a and b to have their own isolated "copies" of c.jar.
    Instead, what I'm finding is that Foo.class is loaded once, and his loader "leaks" over to the other jar's loader, if that makes any sense.
    Is there any way to accomplish what I am talking about here?
    Laird

    As I understand the question - no.Hi; I think you misunderstand the question.
    The classes are being loaded by the system loader.
    Thus there is no way to seperate them.
    If you want them seperate then you must use an
    explicit class loader to load them.I am using explicit loaders to load them. Let me try again, because I don't think I was clear.
    I have an application that has, let's say, nothing at all in its classpath. That is, it was invoked via "java ApplicationMainClass". No classpath.
    Now that application reads, let's say, a properties file containing a list of URLs that point to jars.
    Now the application creates a new URLClassLoader for each such URL. So if the mythical properties file has ten lines, then I create ten classloaders, each of which points to one and only one URL.
    My problem is, even classes loaded by these isolated, separate classloaders are "leaking" across to other loaders. Remember, the parent classloader of all of these classloaders can't see the jars. Its classpath was empty, remember?
    The issue is that the findLoadedClass() method of java.lang.ClassLoader scans the whole VM to see if a given Class was loaded before, and if it was, then by default that Class is simply returned. But I don't want that behavior.
    Now, I also don't want the behavior of having to load the silly things off disk each and every time. So how do I retain this true multiple classloader isolation?
    Thanks,
    Laird

Maybe you are looking for

  • Set Status of next document in CHARM

    Hi Solman experts, I would like to automatically set the status of a "next document" in CHARM. For example if i set a close state for a SDCR i would also like the attached "next documents" to also move to a close state (SDHF etc....). I know this is

  • Can I unlocked an iphone 4s from Verizone to Movistar Phone Line?

    Dear,  can you help me with this please? I have an Iphone 4S. I want to know if This is Unlocked, or If this is Locked, and also I wonder, If my Phone is Locked, can I unloked, or can you unlocked If I get you the model and all the information about

  • N95 v21.0.001 Firmware

    New Firmware will be soon on Nokia Software Updater. Nokia N95 v21.0.001 16-10-07 RM-159 If you find my post useful then click on Kudos!Nokia N96 (v20.050 / RM-247) www.shaysoft.net | Competitions!

  • Premiere Elements 8: Scene Markers Not Frame Accurate on Burned DVDs

    I have Premiere Elements 8, and I have just begun to burn DVDs of projects. I have discovered that the Scene Markers I have carefully placed at precise points in my footage (such as the very first frame of a scene) are not placed at those specific po

  • How to extend the Idoc

    Hi, We need to  pass revision level field from MM PO  to SRM SUS  PO . We checked the message type for this is ORDERS. Now, in this message type there is no revision level field. Our scenario is from MM the idoc goes to XI and from XI XML goes to SRM