Classpath in manifest

I have a main.jar which has a ClassPath, eg
Class-Path: one.jar two.jar ....
And there is many jars. To avoid the problem of forgetting to add one to the classpath, in the event that I add another jar later, is it possible to do
Class-Path: *.jar
In fact, I know the above doesnt work, but is there some way of doing this?
Regards
Cel

Nope. At least not that I have seen. You have to update the manifest file with any newly added .jar files. Keep in mind, the Class-Path refers to jar files on disk, not inside the executable jar file you have the manifest in. Java can't find embeded .jar/.zip files within .jar files to find classes in. If you create a single .jar file with embeded .jar's, you'll have to unjar the main jar to disk first.
However, the opposite is true when dealing with resources. If you use getClass().getResource(), it will look inside the .jar file for the resource.

Similar Messages

  • Classpath and manifest.mf

    what is the difference between classpath, buildpath and a Manifest.mf paths?
    I believe class path is used at run time to look for the classes referred in this path.
    Build path is used to build the application i.e. to link the components used while compiling and building classes.
    Manifest.MF is also used for runtime resolution.
    What different purpose did classpath and manifest.mf serve?

    If I understand you correctly, this is more of a general Java Question then a Java Servlet Question... but anyway...
    The manifest.mf is defined for JARs. Your system CLASSPATH, and the classpath set on the command line are ignored for JARs, and only the CLASSPATH set in the manifest is used.
    When running applications outside of JARs, then the system/command line CLASSPATH is used.
    When running a web application inside a WAR, the server has its own classpath which will override that of the manifest and the system CLASSPATH.

  • Classpath in manifest file

    what is 'classpath' in manifest file used for?
    I tried to create classpath, but doesnt have any significant different....
    thanks
    YAn

    This is what the tutorial says about class-path in a manifest file:
    Download extensions are JAR files that are referenced by the manifest files of other JAR files. See the trail on the extension mechanism for information about extensions.
         In a typical situation, an applet will be bundled in a JAR file whose manifest references a JAR file (or several JAR files) that will serve as an extension for the purposes of that applet. Extensions
         may reference each other in the same way.
         Download extensions are specified in the Class-Path header field in the manifest file of an applet, application, or another extension. A Class-Path header might look like this, for example:
              Class-Path: servlet.jar infobus.jar acme/beans.jar
         With this header, the classes in the files servlet.jar, infobus.jar, and acme/beans.jar will serve as extensions for purposes of the applet or application. The URLs in the Class-Path
         header are given relative to the URL of the JAR file of the applet or application. For more details, see the link shown below:
    http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html
    V.V.

  • Can I specify classpath in MANIFEST.MF of a ear file?

    Hi,
    I know that one can specify classpath in MANIFEST.MF of a jar file, I'd like to know whether I can specify classpath in MANIFEST.MF of a ear file?
    If yes, will the classpath specified affect all j2ee components in this ear file?(e.g. jar files,war files)
    Thanks

    Unfortunately, yes, you'd have to edit the MANIFEST.MF
    of each module within the .ear that has a dependency on
    the bundled library. One workaround is to add the common
    code to the server's classpath. However, that approach
    doesn't work if the common code has dependencies on the
    code packaged within the ejb-jars and .wars themselves.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Problem in exporting library files with project(Classpath in manifest file)

    I've developed a J2EE application client using Eclipse 3.3.1.1, now I want to export my project as a executable jar file but there is a lot of external jar files so when I put their name in Class-Path variable of project's Manifest, I see "Too long" error because there are too many external jar files.
    How I can export required jar files with executable file of my project?
    In my idea, the process of application client exporting is so foolishly and silly! why there isn't any standard and easy-to-use utility for this reason?!

    Nazi wrote:
    I've developed a J2EE application client using Eclipse 3.3.1.1, now I want to export my project as a executable jar file but there is a lot of external jar files so when I put their name in Class-Path variable of project's Manifest, I see "Too long" error because there are too many external jar files.
    How I can export required jar files with executable file of my project?
    In my idea, the process of application client exporting is so foolishly and silly! why there isn't any standard and easy-to-use utility for this reason?!Probably a Jewish Bolshevik conspiracy...
    Abuse reported

  • How to add classpath to manifest

    ok i have a jar called javaquest.jar
    to run it, this works fine:
    java -cp .;javaquest.jar game.GameGUIbut this doesn't:
    java -jar javaquest.jareven when i used this manifest:
    Manifest-Version: 1.0
    Created-By: My Name
    Main-Class: game.GameGUI
    Class-Path: javaquest.jarwhat am i doing wrong?
    thanks

    ok my manifest contains:
    Manifest-Version: 1.0
    Created-By: My Name
    Main-Class: game.GameGUIhere is the command i used to package:
    jar cfm javaquest.jar manifest.txt gamehere is the command i used to run it (and it worked):
    java -cp .;javaquest.jar game.GameGUIwhat i want is for the jar to be double-clickable in windows, which i think means it needs to respond to the command:
    java -jar javaquest.jarwhen i use that command, i get:
    Exception in thread "main" java.lang.NullPointerException
         at javax.swing.ImageIcon.<init>(Unknown Source)here is my file system:
    javaquest.jar
    --game(dir)
    ----[classes]
    ----images(dir)
    ------[images]and here is the statement in the code i am using to retrieve the image:
    a_jlabel.setIcon(new ImageIcon(getClass().getResource("images/image.gif")));Message was edited by:
    lost_in_java

  • How to add multiple classpath in manifest file

    how can I put multiple class path in manifest file

    Double-post: [url http://forum.java.sun.com/thread.jspa?threadID=792634]http://forum.java.sun.com/thread.jspa?threadID=792634.
    Answered in the other thread.

  • Manifesting Classpath Issues + Ant

    Having some problems with classpath and manifest file.
    I'm using ant to build manifest in jar. The classpath seems to be set OK in the manifest.
    I include an external jar(log4j) in my app jar, and it seems to go in the correct place in my app jar(lib directory).
    The manifest file seems to be created OK, and is put in the MANIFEST-INF directory in app jar.
    I can compile and build everything OK.
    The main issue is that at runtime, it does not seem to pickup the log4j jar. I get a NoClassDefFoundError when trying to create a Logger class.
    Any help would be appreciated. I will include relevant information below.
    ant stuff          <jar jarfile="${dist}/lib/mosaixsegment8-${DSTAMP}.jar" basedir="${build}">
                   <manifest>
                        <attribute name="Built-By" value="${user.name}"/>
                        <attribute name="Main-Class" value="com.company.TestClient"/>
                        <attribute name="Class-Path" value="lib/log4j-1.2.8.jar"/>
                   </manifest>
              </jar>
    Manifest File CreatedManifest-Version: 1.0
    Ant-Version: Apache Ant 1.5.4
    Created-By: 1.4.2_01-b06 (Sun Microsystems Inc.)
    Built-By: user
    Main-Class: com.company.TestClient
    Class-Path: lib/log4j-1.2.8.jar
    Code Snippitimport org.apache.log4j.Logger;
    public class TestClient{
         public static void main (String argv [])
              // Get Logger
              org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("name");
    Error Message
    [java] java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    [java] at com.company.TestClient.main(Unknown Source)
    [java] Exception in thread "main"
    [java] Java Result: 1

    pkwooster,
    If there are complex solutions then the problem must be complex and perhaps I did not understand the problem (it takes a few hits on my head for the problem domain to get cleared up :). Reason I say this is because my problem is not complex & neither is the solution.
    What I have is this:
    1. Manually created (I know ANT does this; but I didn't use ant; I used a sh script) the MF file with just the Class-Path defined.
    Here is the MF entry from my standalone application (it is really a messaging application):
    Class-Path: log4j-1.2.7.jar bta_notify-facade-client.jar bta_notify-ex
    ception.jar bta_notify-vo.jar
    2. IN my sh script I use the following command to create my jar:
    jar cvfm $BTA_ADAPTER_JAR_OUT \
         meta-inf/adapter-manifest.mf \
         $BTA_ADAPTER_CLASSES/*.class \
         $BTA_EXCEPTION_CLASSES/*.class \
         $BTA_MESSAGE_CLASSES/*.class \
         $BTA_VO_CLASSES/*.class \
         $BTA_GRAIN_BEAN_CLASSES/*.class \
         -C $BTA_SRC_CONFIG_DIR log4j.xml \
         -C $LOG4J_DIR $LOG4J_JAR
    (the BTA_EXCEPTION_CLASSES & BTA_VO_CLASSES are not the same as the jars mentioned in the mf classpath).
    That is all that I did. The adapter.jar contains log4j.jar (without the path) & the mf (meta-inf/ as the path).
    I did something very similar on a j2ee app that is deployed as an EAR file in weblogic. That is where I have ear containing jar1 which contains log4j, other jars & jar1's mf which lists these contained jars (log4j & others) in its classpath.
    I presume my problem & the problem that is being solved by these other complex solutions are not the same.

  • Add classpath in an executable jar file

    an executable jar file contains a manifest file with entry main-class: MyApplicationClass.
    if we double click the jar file on Windows OS, main class is loaded.
    my question is:
    if classes in he jar file use classpaths which are not default, how to add those classpaths into manifest file to tell classes to use those classpaths?
    it is similar to command line:
    java -classpath c;\mypackage; .......; MyApplicationClass

    Thanks, i will try soon.
    here is another Q.
    if i need to add tools.jar (JDK lib) as classpath in manifest file, it is as following in my PC
    d:\install\java\jdk14101\lib\tools.jar.
    but my customers install JDK in different path (should be considered as unknown), how to add it as entry Class-path for all customers?

  • IconService and classpath in executable jar file

    I use JDIC project (https://jdic.dev.java.net/) and want to use its incubator project iconService as well - both of them in one project. When I run my program from within Eclipse 3.1 IDE, everything works.
    But if I export it to a jar file, the program does not run. I found out that Eclipse 3.1does not create the manifest file correclty. When using only JDIC, I wrote this line to the Manifest file and the exported jar worked:
    Class-Path: external_libs/jdic-0.9-bin-cross-platform/jdic.jarBut when I try to add also the other library - Iconservice to the classpath of the Manifest file like this:
    Class-Path: external_libs/jdic-0.9-bin-cross-platform/jdic.jar external_libs/Icon_service/jdic_icon.jar the console writes out these errors:
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at Frontend.Mainframe.getIcon
    Caused by: org.jdesktop.jdic.spi.ProviderException: Provider org.jdesktop.jdic.icons.impl.WinIconProvider  can not be found
    at ...
    I suppose that the program cannot find the needed "jdic_icon.dll" but I do not know how to set the path to a dll into classpath of manifest file.
    Can anyone help me?
    Thanx in advance.
    Lubos.

    [This is a cross-post of http://forum.java.sun.com/thread.jsp?forum=424&thread=453226]

  • Startup problem: cannot read manifests

    I have encountered this problem during weblogic startup, can anyone give me some hints?
    The WebLogic Server did not start up properly.
    weblogic.common.internal.VersioningError: Cannot read manifests from CLASSPATH: invalid manifest format
    at weblogic.common.internal.VersionInfo.<init>(VersionInfo.java:41)
    at weblogic.common.internal.VersionInfo.initialize(VersionInfo.java:120)
    at weblogic.common.internal.VersionInfo.theOne(VersionInfo.java:91)
    at weblogic.version.getPLInfo(version.java:57)
    at weblogic.t3.srvr.T3Srvr.checkAccess(T3Srvr.java:517)
    at weblogic.t3.srvr.T3Srvr.initializeHere(T3Srvr.java:702)
    at weblogic.t3.srvr.T3Srvr.initialize(T3Srvr.java:664)
    at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:342)
    at weblogic.Server.main(Server.java:32)
    Reason: Cannot read manifests from CLASSPATH: invalid manifest format

    "Alfonso Wong" <[email protected]> wrote in message news:[email protected]..
    I have encountered this problem during weblogic startup, can anyone give me some hints?
    The WebLogic Server did not start up properly.
    weblogic.common.internal.VersioningError: Cannot read manifests from CLASSPATH: invalid manifest format
    at weblogic.common.internal.VersionInfo.<init>(VersionInfo.java:41)
    at weblogic.common.internal.VersionInfo.initialize(VersionInfo.java:120)
    at weblogic.common.internal.VersionInfo.theOne(VersionInfo.java:91)
    at weblogic.version.getPLInfo(version.java:57)
    at weblogic.t3.srvr.T3Srvr.checkAccess(T3Srvr.java:517)
    at weblogic.t3.srvr.T3Srvr.initializeHere(T3Srvr.java:702)
    at weblogic.t3.srvr.T3Srvr.initialize(T3Srvr.java:664)
    at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:342)
    at weblogic.Server.main(Server.java:32)
    Reason: Cannot read manifests from CLASSPATH: invalid manifest format
    ***************************************************************************I'd check if custom jars in you server classpath have valid MANIFEST.MF
    HTH
    Regards,
    Slava Imeshev

  • Could not find the main class error with executable jar

    Hello,
    I have troubles creating an executable jar file and I ran out of ideas how to solve it so I would appreciate some help.
    I have created a jar file with the export function in eclipse
    the Manifest.MF file contains:
    Manifest-Version: 1.0
    Main-Class: view.AppTennisViewI tried starting the file with a batch file which contains following code:
    @echo off
    javaw -classpath c:\TennisHSQLDB_GC2\tennisApp.jar
    @start javaw -jar tennisApp.jar
    exitthe batch file and the jar are both located in c:\TennisHSQLDB_GC2.
    When i try command line I get the same result.
    I also tried alternate statements such as SET CLASSPATH iso javaw -classpath and including the classpath in the manifest file but no luck. It keeps given me the error: could not find the main class. program will exit
    Anyone any suggestions for my problem?

    nevermind, found it.
    classpath in manifest was incorrect

  • Internal JAR package loading???

    Ok I hate having to come to forums and bother other people,
    but hopefully someone will know and be able to aid me in some way...
    It's driving me absolutely insane...
    Alright I've made an application. Basic application that display Hello World
    in a JLabel. That's all. But here the catch, it uses the GUI jar's from
    netbeans. Java Studio 8 uses them, and apparently they dont come
    standard with java, or i wouldnt be here...
    So goal = Somehow JAR and load the required packages with the main application for use with JNLP web start.
    I have tried editing the MANIFEST.MF in many ways to get the
    CLASSPATH to load the JAR packages(Which happen to be:AbsoluteLayout.jar),
    but no luck.... I have also tried using Certificates to be able to externally
    load the package i need, and no luck...
    C:/Web_Server/test.jnlp // Open's Java Program in Web Start
    |---->C:/Web_Server/test.jar // The Main Program
    |---->C:/Web_Server/lib   //External Package Directory(holds AbsoluteLAyout)
    |-------->C:/Web_Server/lib/AbsoluteLayout.jar // the package i need to run test.jarNow get this... It will load successfully if I run the JAR file, but if i try the web start JNLP, it brings back:java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout%GroupThis is because it's not loading the lib/AbsoluteLayout.jar.
    If I delete the lib folder and attempt loading the JNLP with the lib packages in the test.jar, it brings back "noMainClassDefError".
    ------------------ In-Short ------------------
    For those who didnt understand/read the above:
    I Made an Application w/ Java Studio 8.1
    Cannot distribute it to Web using JNLP.
    Because:
    1.) Classpath in Manifest only loads outside test.JAR(and certificates dont help)
    2.) Java is being a cunt.
    Help is GREATLY appreciated, im about to pop a few blood vessels.

    haha i found my own answer on accident while browsing for a different problem....
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4027734
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4027734http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4027734
    WHOOOO!!

  • OSB Java Callout, no methods shown when selecting jar

    Hi,
    I'm trying to invoke a Java method in OSB. I've already done this before with a simple static method. What this time is diffrent is that now my jar contains dependency to another jar, like Xerces.
    After I've imported my jar, and I'm trying to select a method, there is no method for me to select. I've tried doing it in either osb console, and OEPE.
    I suspect that the reason for this is the fact that there are imports in the jar. The things I've tried:
    * putting all the imported jars in classpath in MANIFEST file in the jar,
    * importing the imported libraries to osb as well,
    * putting imported jars in the lib directory of the domain (and restart),
    * adding all the imported jars to the servers classpath
    but to no avail.
    Or it could not be related to the imports at all.
    Method signature:
    public static String prepareEnvelope(String envelope) throws TransformerException, SAXException, IOException
    Help? Suggestions?
    Edit: OSB console doesn't seem to see this method either:
    package myPackage;
    public class Test {
         public static String test(String arg) {
              return "kitten";
    What's going on?
    Edited by: Veronica on Dec 13, 2012 2:59 AM

    I seem to have resolved my own problem. I complied the Java project using Eclipse and Java 1.6. After I've changed the "compiler compliance" from 1.7 to 1.6, my project is being shown in OSB.
    Yay

  • Glassfish cannot find sapjcorfc although available

    Hello!
    On a 32Bit Linux machine, I installed the sapjco-linuxintel-2.1.8.tgz by
    - copying the sapjco.jar into glassfish/domains/domain1/lib directory
    - copying included libsapjcorfc.so and librfccm.so into glassfish/lib directory
    stefan@server:~$ ls -al /usr/share/glassfish/lib/
    insgesamt 61140
    drwxr-xr-x 15 root root 4096 2008-02-25 15:30 .
    drwxr-xr-x 12 root root 4096 2008-02-13 18:33 ..
    ... some other files ...
    -rwxr-xr-x 1 root root 5046073 2007-01-08 21:40 librfccm.so
    -rwxr-xr-x 1 root root 3827533 2007-01-08 21:40 libsapjcorfc.so
    ... some other files ...
    stefan@server:~$
    When I now access a Bean that wants to make a call via JCo, my server logs give a lot of Exception, with the following being the main trouble:
    at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    Caused by: java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'
    JCO.nativeInit(): Could not initialize dynamic link library sapjcorfc [/usr/share/glassfish/lib/libsapjcorfc.so: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory]. java.library.path [/usr/share/glassfish/lib:/usr/share/glassfish/lib:/usr/share/glassfish/lib]
    at com.sap.mw.jco.JCO.<clinit>(JCO.java:776)
    In other words, it cannot find the libraries, although they are available.
    I tried a number of different things:
    - the libsapjcorfc.so in the directory only
    - providing a dynamic link called sapjcorfc.so to libsapjcorfc.so
    - let sapjcorfc.so be a copy of libsapjcorfc.so
    nothing helped.
    I'm using the latest Ubuntu version incl. all updates.
    Can anybody help me please?
    Regards,
    Stefan

    Hello Eray!
    Thanks for your reply.
    I tried that, but now I get
    Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sap.mw.jco.JCO
    Therefore I tried to set the CLASSPATH
    - in MANIFEST.MF
    - when deploying the Bean in Glassfish (there is an option that allows you to do so)
    ... both without any success / change (see the Exception above).
    it does now look like the following:
    glassfish/
    bin/sapjco.jar
    bin/libsapjcorfc.so
    bin/librfccm.so
    domains/domain1/lib/sapjco.jar
    ..but is not working.
    I also tried:
    glassfish/
    bin/sapjco.jar (links to ..domains/domain1/lib/sapjco.jar)
    bin/libsapjcorfc.so
    bin/librfccm.so
    domains/domain1/lib/sapjco.jar
    and
    glassfish/
    bin/libsapjcorfc.so
    bin/librfccm.so
    domains/domain1/lib/sapjco.jar
    ... but that didn't work either.
    ...everytime with the classpath set to /usr/share/glassfish/bin/sapjco.jar or /usr/share/glassfish/domains/domain1/lib/sapjco.jar respectively.
    Using Windows, the following setup works:
    glassfish\
    lib\sapjcorfc.dll
    lib\librfc32.dll
    domains/domain1/lib/sapjco.jar
    Do you have any other idea?
    Thank you lots.
    Regards,
    Stefan

Maybe you are looking for

  • Can't get rental to sync from comp to iphone

    Help! I rented a movie from iTunes, and it shows up in the rented movie section. When I click on the video tab for the iPhone, the movie doesn't show up. When I sync the phone, the movie doesn't transfer. Any ideas?

  • Final Cut Pro X Export Error

    When exporting my project I get an error (Quicktime Error -50). I narrowed it down to a video that I am using within my project. I didn't film it it's a video that was sent to me from a client to splice in throughout the video. I exported it without

  • SOAP Sender Adapter -- Only 1 Service Interface possible ?

    Hi all, I have the following situation (only relevant components are described) I created a Communication Channel: SOAP_Sender_X And I created a Sender Agreement for ServiceInterface A with Soap_Sender_X Then I call ServiceInterface A. All is OK Then

  • Create T.Code for a query (Report looks like VF05)

    Hi, I'm facing a problem right now.. I made a Query with SQVI, then I converted it with SQ01.. It is a report that lookes like VF05 but has the column EAN/UPC Code added on it. Now I am trying to create a T.code to run this report, using SE93. So, I

  • BI 7 New Business Content

    Dear Team, If anybody having list of new business content available in BI7(2004S) for MM, PP, SD and FICO please send me to [email protected] Best Regards, SG