Manifest and classpath

How do you update the classpath information in the manifest of a jar file?

It appears to be simple and yet the documention doesn't tell the whole story. I've poured over it and have not been able to add a Class-Path: variable successfully yet.
I use the format
jar cmf mymanifest myjar.jar myclass.class
It adds the class it changes the time the manifest was created but is still only the default manifest.
Here is my manifest--
Manifest-Version: 1.0
Created-By: 1.3.1_02 (Sun Microsystems Inc.)
Class-Path: ExceptionKiaobjects.jar
According to the specification this looks correct. I get no errors. I don't get it.

Similar Messages

  • Manifest and classpath frustration

    I have a very simple standalone application. It is not an applet - it's a simple command line program that parses an XML stream and stores the results in a database. This app depends on a ton of external jar files. I would like to be able to build and run this thing - on different platforms - without having to mess with a bat or sh script. From perusing the web, it seems like I should be able to do this with a custom manifest file ... but I can't seem to get it to work. I keep getting a class not found error. In a nutshell, my jar looks like this
    lib
    com
    META-INF
    Insid the lib directory are around a dozen jar files
    Inside the com directory are all my class files
    Inside META-INF is the manifest file.
    My manifest file looks like this:
    Main-Class: com.mainClass.RunMe
    Class-Path: lib/jarOne.jar
    **lib/jarTwo.jar
    **lib/jarThree.jar
    Note that the *'s indicate spaces and I do have a blank line at the end of file.
    When I try to execute using:
    java -jar myJar.jar
    I continually get class not found errors. If I run in verbose mode, I can see that my classes aren't getting loaded.
    Can I do what I'm trying to do? Any pointers would be greatly appreciated as I'm running out of ideas and patience.
    THanks

    This isn't always legal. You can't "legally" assume you can extract any commercial jar file and bundle it with your app. If everything is open-source then there should be no problem. But for commercial apps, this wont work, at least legally.
    There are two solutions that work best. One is to use an installer that provides an executable launcher (.exe on windows, .sit on mac, etc). This will provide a setup.exe (or setup.sit or setup.sh or something for each platform), that will then install your app like a commercial application. This will take care of unzipping everything you want in the right directories. There are a couple of free/open-source installers, VAInstall is one that I can think of that aren't too shabby. At work we use Install4J which is pretty good.
    The other way is to use a custom classloader. First, your initial "main" class is nothing but a stub loader. It simply creates an instance of this URLClassloader subclass. You use it to find and run your "real" main() method within the classpath. URLClassLoader has a protected addURL(), but the constructor allows you to pass an array of URL objects, each that can be a directory of .class files or specific .jar/.zip files that become the classpath for the classloader instance. With this info, you can use a custom loader to add each of your .jar files located on disk as part of the classpath. The problem is, if they are on-disk, this isn't helping. What your custom loader needs to do is override loadClass(), getResource() and so forth, and provide a way to find classes from embeded jar/zip libraries inside the main jar file. This way, each time any class uses a class in an embeded jar/zip, your custom classloader looks inside the embeded jar/zip files for it as well. It's not prettty, but it works well.
    One final thought, a plugin engine based application framework is a way to go. My own project, www.platonos.org (sorry, as of this posting the site is not up yet, but the project at sourceforge is available and CVS contains the code) can solve these issues. In our plugin engine, which is about 70K, each plugin has it's own classloader and classpath, and our PluginClassLoader not only handles embeded jar/zip files, but resources as well within them. Also, a plugin first searches its classpath before going to the parent to find classes, with the exception of java classes which are delegated to the bootstrap loader which is what loads rt.jar.

  • Set path and classpath in ANT

    by using ANT, how can set the JDK path and classpath..
    jdk version exists in the : C:\Program Files\Java\jdk1.6.0
    This is the build.xml that i need to modify!
    -Do i need to have a serperate JAVA_HOME variable?
    <?xml version="1.0"?>
    <!--
    Build file for 'Chat Client'
    Version: $Revision: 4.10 $ $Date: 2003/05/28 $
    Author:  Rajat Gupta
    -->
    <project name="Chat" default="jar" basedir=".">
       <!-- ================================================================== -->
       <!-- Initialization of all property settings                            -->
       <!-- ================================================================== -->
       <target name="init">
          <property name="appname"        value="chat"   />
          <property name="src.dir"        value="src"               />
          <property name="lib.dir"        value="lib"              />
          <property name="build.dir"      value="Chat"            />
          <property name="build.compiler" value="classic"          />
       </target>
       <!-- ================================================================== -->
       <!-- Makes sure the needed directory structure is in place              -->
       <!-- ================================================================== -->
       <target name="prepare" depends="init">
          <mkdir dir="${lib.dir}" />
          <mkdir dir="${lib.dir}/META-INF" />
          <mkdir dir="${build.dir}" />
       </target>
       <!-- ================================================================== -->
       <!-- Compilation of the web part of the application                     -->
       <!-- ================================================================== -->
       <target name="classes" depends="prepare">
          <javac srcdir="${src.dir}/oracle/otnsamples/oc4jjms"
                 destdir="${lib.dir}"
                 includes="**" />
       </target>
       <!-- ================================================================== -->
       <!-- Compilation of the complete J2EE application (both web and EJB)    -->
       <!-- ================================================================== -->
       <target name="j2ee-meta-inf" depends="classes, prepare">
          <copy file="${src.dir}/META-INF/application-client.xml"
                tofile="${lib.dir}/META-INF/application-client.xml" />
          <copy file="${src.dir}/images/oralogo.gif"
                tofile="${lib.dir}/oralogo.gif" />
       </target>
       <target name="jar" depends="j2ee-meta-inf">
       <jar jarfile="${build.dir}/${appname}.jar"
           basedir="${lib.dir}" manifest="${src.dir}/META-INF/MANIFEST.MF"/>
          <delete dir="${lib.dir}" />
       </target>
    </project>Message was edited by:
    jugp

    [url ='http://www.jguru.com/forums/home.jsp?topic=Ant']answer here

  • Ears, wars, support jars, and CLASSPATH

    I am trying to migrate an application from WLS 5.1 to 6.1. There are 25
    EJB jars with an equal number of support jars, most of which are referenced
    by multiple EJBs. There are also a large number of jsps, and html pages.
    I have tried packaging an ear that contains the 25 ejb jars, a war file
    containing the web pages. I have attempted to include the support jars in
    the ear as well.
    In all attempts, the only way I get class references sastisfied is to
    include all the jars on the system CLASSPATH. But this defeats the purpose
    of packaging, since none of the components referenced in the system
    CLASSPATH will be re-deployable.
    The online documents refer to separate class loaders and classpaths for the
    war and ejbs, but no detail as to how classes are found by the loaders.
    Unless I put all the jars into the CLASSPATH, jsp pages cannot reference the
    EJBs, and EJBs are unable to reference other EJBs.

    Thanks,
    Now if I could just get Webgain Visual Cafe to allow me to include the
    Classpath entries in the generated manifests for the EJB jars.
    "Gregory Gerard" <[email protected]> wrote in message
    news:3ba24da1$[email protected]..
    You need to mangle all the Manifest files within the EAR and EJB-JARs and
    WAR to get the right thing to happen. Check out this PDF on Sun's site:
    http://java.sun.com/j2ee/j2ee-1_3-pfd4-spec.pdf
    section 8.1.1.2
    I don't entirely understand all the restrictions and formatting -- Ihaven't
    found an example ear file out there that implements a non-trivial case.
    greg
    "Carl Lawstuen" <[email protected]> wrote in message
    news:3ba21d8e$[email protected]..
    I am trying to migrate an application from WLS 5.1 to 6.1. There are
    25
    EJB jars with an equal number of support jars, most of which arereferenced
    by multiple EJBs. There are also a large number of jsps, and htmlpages.
    I have tried packaging an ear that contains the 25 ejb jars, a war file
    containing the web pages. I have attempted to include the support jarsin
    the ear as well.
    In all attempts, the only way I get class references sastisfied is to
    include all the jars on the system CLASSPATH. But this defeats thepurpose
    of packaging, since none of the components referenced in the system
    CLASSPATH will be re-deployable.
    The online documents refer to separate class loaders and classpaths forthe
    war and ejbs, but no detail as to how classes are found by the loaders.
    Unless I put all the jars into the CLASSPATH, jsp pages cannot referencethe
    EJBs, and EJBs are unable to reference other EJBs.

  • Difference between path and classpath

    Difference between path and classpath?

    PATH - set of paths there executables will be found.
    CLASSPATH - set of paths and archives there class files will be found.

  • Problem with Class and Classpath

    Hello ME Windows Users, now before you place a wry smile on your face, I have a problem with path and classpath. Stop it, I can see you smiling!
    By visiting the the last 10 pages of the forum and reading Sun installation notes, some tooldocs and by given some answers by some nice people, I have become an expert in turning off my computer, about 10 times/hr. I still am trying to make my first cup of java.
    With the ME computer,
    I'm unable to right click on the desktop and go to properties, advanced,
    I'm unable to go go start, run, sysedit,
    I'm unable to change the ms-dos window of autoexec.bat, it just shuts down.
    Now before you tell me, I should of bought a different computer, the only place I can find to modify the path and classpath is in the environment which is in system configuration under tools. Here I have placed numerous configurations, like
    C:\java>set path=%path%;c:\j2sdk1.4.2\bin
    C:\java>set classpath=%classpath%;.;
    ;java_dir\bin where ;java_bin is c:\j2sdk1.4.2
    .; java_dir\bin; %path% where ;java_bin is c:\j2sdk1.4.2 and the list goes on.
    But, I know you are still smiling, the % signs comes up in a dialog box, saying too many, and will not convert the text to the environment to be saved when I close down for the tenth time in the last hour.
    Can someone help me before I make a real cup of coffee and accidentally drop it on the ME box.
    Have a laugh on me Mik.

    C:\java>set path=%path%;c:\j2sdk1.4.2\binGood
    But it is no good because it has to many % and a dialog box appears, saying you have too many parameters.
    Are you saying I have to shutdown again to answer your ?
    From the HELP menu-
    To confirm startup commands line by line
    Click Start, and then click Shut down.
    Click Restart, click OK, and then press and hold the CTRL key until the Windows Startup Menu appears.
    Enter the number for Step-by-step confirmation, and then press ENTER.
    For each command you want to run, press Y.
    If the command runs successfully, you are prompted with the next command.
    If the command does not run successfully, you receive an error message.
    To skip a command, press N.
    Mik

  • Path and classpath

    How do i set path and classpath in java? why it is needed

    ramyabaskar wrote:
    How do i set path and classpath in java? why it is neededTypically you do not set these in java.
    You set the path in the operating system shell.
    You set path so you can launch java by just typing java
    instead of having to type the full path to "C:\Program Files\Java\jre6\bin\java.exe".
    You pass the desired classpath to java when you launch java with the classpath option or set it in the operating system shell using the CLASSPATH env.var.

  • How to go about Setting PATH and CLASSPATH?

    I have problems compling the helloworldwww in the core programming.the error was:
    Exception in thread "main"java.lang.NoSuchMethodError:main
    my java programs are in c:\program files\java\bin
    My path :
    PATH=C:\WINNT\system32;C:\WINNT;c:\program files\java\bin
    My classpath
    set CLASSPATH=C:\WINNT\system32;C:\WINNT;c:\program files\java\bin.jar;.
    is there any error in my paths, if yes how to i go about setting the path and classpath??Im running on winXP.j2sdk1.4.1_02.

    set CLASSPATH=.;c:\program files\java\bin.jar;c:\program files\java\bin

  • How to set packages and classpath

    Hi,
    I want to know about packages and classpath. I have these questions
    1, If I put a class in a package(work.util) is it necessary to put the java file in the same directory/directory hierarchy as mentioned in the package declaration. I have to compile this class, run it from main method and must be able for other classes to import.
    2. If a package have subpackages(work.util.db) do I have to set the classpath to subdirectory also to run that class.
    3. If a class is in package is it possible to run the class without prefixing the package name. I need to do this in the text editor so that I can run any program by pressing a hot key.
    rgds
    Antony Paul

    1, If I put a class in a package(work.util) is it
    necessary to put the java file in the same
    directory/directory hierarchy as mentioned in the
    package declaration.Strictly speaking, this isn't covered by the spec - it depends on what compiler and ClassLoader you are using. If you're using Sun's JDK, then yes.
    2. If a package have subpackages(work.util.db) do I
    have to set the classpath to subdirectory also to run
    that class. No. You should add the directory above work/util/db to your classpath. You should not add work, or work/util or work/util/db.
    E.g., if your Java files are in C:/MyProject/JavaSrc/work/util/db, and the package name is work.util.db, then you should have C:/MyProject/JavaSrc on your classpath (or have "." (dot) on your classpath, and compile and run from that same directory).
    3. If a class is in package is it possible to run the
    class without prefixing the package name. I need to do
    this in the text editor so that I can run any program
    by pressing a hot key.If you mean "in order to run work.util.db.Main do I need to type java work.util.db.Main, or just java Main", then you do indeed need the fully qualified class name (otherwise, how would the runtime environment know which class you mean? - there could be any number of classes called Main in any class, and it would have to search every directory and subdirectory on your classpath to find them.

  • Problem in setting path and classpath for java in RedHat linux 9

    Hi ,
    i am not able to set the PATH and CLASSPATH for j2sdk1.4.2_06
    I have tried with export PATH=$PATH:/usr/j2sdk1.4.2_06/bin
    and export CLASSPATH=$CLASSPATH:/usr/j2sdk1.4.2_06/lib
    in terminal
    but i want to configure it as permenant way for the jre and jdk
    and we should only type java or javac according to the requirement
    regards mihir...

    type those in .bashrc ... save and exit
    then at prompt, type 'source .bashrc'
    this is the permanent solution ...
    bhalo thakun

  • Package and CLASSPATH

    Hi,
    I have a hard time understanding the package and CLASSPATH. I want to have a solid understanding of it. I read some tutorials online but didn't make me fully understand. How does declaring a package effect the CLASSPATH? Say I have following:
    (This is from one of the tutorial- http://home.cogeco.ca/~ve3ll/jatutor4.htm)
    C:\myclasses\world\moon\HelloMoon.java
    C:\myclasses\world\HelloWorld.java
    HelloMoon.java is defined as
    package world.moon;
    public class HelloMoon {
    private String holeName = "rabbit hole";
    public String getHoleName() {
    return holeName;
    public void setHole(String holeName) {
    this.holeName = holeName;
    public static void main(String[] args){
         HelloMoon moon = new HelloMoon();
         System.out.println(moon.getHoleName());
    HelloWorld is defined as
    package world;
    public class HelloWorld {
    public static void main(String[] args) {
    System.out.println("Hello World");
    if the CLASSPATH is set : set CLASSPATH=.;C:\myclasses;
    Once the CLASSPATH has been set (and compiled .java file); it can be called using the following from any path of directory:
    java world.HelloWorld
    java world.moon.HelloMoon
    But it does not explain the details why it works this way. Also, if I want to run it without using "world" prefix to run HelloWorld, what do I need to set up?
    also for the HelloMoon?
    When I tried running those classes by going to an appropriate directory, I got the noClassDefFound (using command like "java HelloWorld" or java "HelloMoon").
    Thanks in advance...

    [Javapedia: Classpath|http://wiki.java.net/bin/view/Javapedia/ClassPath]
    [How Classes are Found|http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html]
    [Setting the class path (Windows)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html]
    [Setting the class path (Solaris/Linux)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html]
    [Understanding the Java ClassLoader|http://www-106.ibm.com/developerworks/edu/j-dw-javaclass-i.html]
    java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
    javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

  • Setting System properties and classpath at boot

    Hi all,
    I'm pretty new to weblogic and I'd need to set some system properties and classpath definitions for my servers at boot. Can I set them via the Administration console or just adding them to the startWeblogic/startManagedWeblogic using the standard -cp and -D flags ?
    I've found in the Console, there's the Server Boot properties. However adding them there didn't work. Correct me if I'm wrong, this option can be used ONLY when starting the servers from the Node Manager ?
    Thanks
    Frank

    Hi Frank,
    You are right!!!!
    But you can set them with in setDomainEnv file under java_option.
    Please set under
    Unix
    JAVA_OPTION = "${JAVA_OPTION} -DXXXXX"
    In Windows
    set JAVA_OPTION = %JAVA_OPTION% -DXXXXX
    Hope this will help you.
    Regards,
    Kal

  • Libraries and Classpath option panel is empty

    Hi All,
    Just installed Jdeveloper 11g 11.1.1.1.0 on Vista 64b.
    Added my jar file into "Manage Libraries" whent to the project properties, "Libraries and Classpath", but this pannel is empty, blank, does not have any options....
    Any ideas what is wrong?
    Jar file itself already copied in to the project, so I do not have issue of using it
    Thank you.

    Hi,
    the same environment but when I go to project properties, "Libraries and Classpath" I can see all my project libraries and also Add library... button shows my jar to add to Project
    regards,
    Branislav

  • Enhancement Request in Project Libraries and Classpath dialog

    Hello,
    in the Libraries and Classpath section of the Project Properties we can move up/down single classpath entries only. Adding some libraries and ordering them is pretty much work.
    Please allow moving multiple selected entries (this was possible in 904).
    From our point of view libraries should be added at the beginning of the list. Most times we add user defined libraries that we want in the beginning of the classpath.

    Hi,
    I filed an ER
    Frank

  • [NOTE] bpelx:exec and classpath

    ===============================
    QUESTION
    ===============================
    We have been receiving a lot of emails lately about the use of Java embedding and classpath information.
    ===============================
    ANSWER
    ===============================
    The answer is that any classes used in the inlined <bpelx:exec> code snippet needs to be either in the global classpath or preferably packaged in the BPEL-INF\classes or BPEL-INF\jar section of the BPEL suitcase (pattern which is very similar to how .war archives work).
    For more information please refer to:
    1) C:\orabpel\samples\references\JavaExec
    2) C:\orabpel\samples\demos\LoanDemoPlus\LoanFlowPlus
    Both examples uses an ant script to compile the dependent classes into <bpel project folder>\BPEL-INF\classes.
    Like for .war archives, there are more sophisticated options offers by bpelc to just in time copy .jars into the BPEL-INF\lib folder of the generated war.
    I hope that this note will address so of the questions people have in this area until we build out our documentation.
    Edwin

    how about writing the path in the <applet codebase="path"> attrib?

Maybe you are looking for

  • After Effects CS5 DNxHD rendering problems

    Hello folks, I posted this last month, but still haven't worked it out.  My problem is that everytime I try to render a quicktime from After Effects CS5 using Avid's DNxHD codec, I get this error, about 60 - 100 frames in:  "Rendering error while wri

  • Crystal Reports 2008 and printing with Zebra printer issue

    Hello, Since we have upgraded the reports from XI to 2008, the reports are not printing well in the Zebra printers. The report gets shrunk to half the size. Is there something that needs to be done after the upgrade? Thanks in advance

  • Export avi

    Hi. I'm having trouble in exporting avi files from imovie. I'm importing from camera (imovie divides in clips, how to stop this?) and exporting the entire tape to file (.avi), but it just exports the first 3 or 4 minute, though the file has 12 gigas.

  • MYSAPSSO2 - JSPDynPage - (Re)Authentication Issue

    Good Afternoon, I have created a JSPDynPage and deployed on an EP7.0 2004s SP14 server.  You can access the JSPDynPage by using http://host:port/irj/servlet/prt/portal/prtroot/<jsp_dyn_class> When I browse to the location I am challenged for credenti

  • Mac Office Test Drive Software

    Can anyone tell me how to get my computer to recognize my installed and registered version of mac office instead of the test drive software that came installed on the computer. I am assuming there is someplace to set this option - as of right now, an