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.

Similar Messages

  • 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.

  • 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.

  • Can anyone tell me where to send my i phone to for repair?? I have paid by card on this site but been given no details as to what address it is to be sent . i am not a computer whizz but not an idiot either and i am becoming more and more frustrated !!!!!

    Can anyone tell me where to send my i phone to for repair?? I have paid by card on this site but been given no details as to what address it is to be sent . I am not a computer whizz but not an idiot either and i am becoming more and more frustrated !!!!!

    Yes, AppleCare can tell you.  Below is the number for AppleCare in the US. 
    1-800-APL-CARE *
    1-800-275-2273
    Hours of Operation: 7 days a week from 5am - 8pm Pacific time.
    If you live outside the US, additional contact information can be found at this link.
    http://support.apple.com/kb/he57

  • 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

  • Worst and most frustrating experience in twenty years of software use

    February, 2010 I purchased Photoshop Elements 8.  I registered it, got a website dedicated to my screen name, etc.  I finally got the time to accumulate all my photos into organizer and organize them.  It took me two days.  I went in today, the third day, and the software won't open because there's a popup screen from Adobe for me to upgrade to Photoshop Elements 9.   The pop-up doesn't have a close button on it.  I can't get into the software I've paid for because Adobe wants to sell me more software.  After two days of use, I have no intention of sending them more money to use software I already have.  So then I called Support and waited on hold for 25 minutes only to be told I need TECH support and am put back on hold for another five minutes.  After 1/2 hour total on hold time, they tell me that Adobe Photoshop 8 is a pay-for-support product.  YOU ARE KIDDING ME!  They want $39 from me to answer the question of why the software they sold me won't open because they are trying to sell me an upgrade and forgot to put a Close button on the pop-up? 
    The guy says there's an answer on the forum for the problem.  Well, I searched the forum.  I didn't see an answer.  Maybe it's here.  I don't know. 
    So I'm really just trying to scream here and see if anyone at Adobe listens or cares enough to be able to address their failure. 
    By the way, I was working with the purchasing department on a competition for use of imaging and document management software to satisfy regulatory compliance requirements for the global consulting firm where I work.  Probably a multi-million dollar long term deal.  Nice that they've blown that over $39 Support fee trying to get a $60 upgrade out of me after two days of using properly purchased, licensed, registered software. 
    Oh, I forgot to mention that the e-mail with which I registered doesn't show as registered, despite my having a web-site set up for me and despite them being able to find me to try and sell me upgrades, they can't find me when it's time to provide assistance.   
    This is hands down the worst product support and most frustrating experience of using software I have had in well over twenty years as a software user.  Nothing else has even come close - including situations that resulted in lawsuits!
    - Derek Zurfluh

    Derek,
    Off hand I don't remember the remedy for your predicament, there is one, but in the meantime go to the PhotoshopElementsEditor.exe file (or similar, this is PSE9) and hopefully start the software by double clicking on it.
    Juergen

  • 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

Maybe you are looking for

  • How to play 5.1 audio with my Mac Book Pro Retina?

    I recently received several DVD's that have 6 channel LPCM 24/192 and 24/96 sound.  I have tried many alternatives  but to no success.  I will appreciate any suggestions...  Sincerely,  Joe Ray Skrha [email protected]

  • Problem with access JSF applet using javascript

    Can someone help me! I'm using a applet in jsf page, and i'm trying to access this applet using a javascript. Here is the applet code <jsp:plugin code="DoAction.class" codebase="." height="400" hspace="10" jreversion="1.5" type="applet" vspace="50" w

  • Catalog Item Maintenance

    Hi Gurus, Is there a way to be able to keep the item prices in the catalog up to date? Right now, if there are 2 contracts created for item 1 given that the 1st contract has expired so the 2nd contract was created -- the catalog will still show items

  • How can I use Private browsing alongside already open regular browsing window?

    ''Duplicate post, continue here - [https://support.mozilla.com/en-US/questions/816143]'' Hi, Whenever I start Private browsing, all the tabs and windows which are already open closes and then the Private browsing window opens. All the tabs and window

  • Emails reading as gibberish

    Hi. I'm using Safari 1.3.2 on OSX 10.3.9 on my iMac. When I view emails in .mac or in Yahoo! some of the text is gibberish. The letters look weird. Like Greek or Chinese. But they're not intended to be. It's not junk email either. They're emails from