Using classpath in executable jar creation

Hai all
I want to create an executable jar file for my aaplication...I know how to do that using jar command..My application in using many jar files.So in manifest file I have to declare the classpath property....
The problem is the the number for jar files more so that when I give names of all it is giving me error message while running the jar commad..
Can I add all the jars to a zip something like file so that I have to mention only 1 entry for classpath...
I am not sure it will work...I think that it may not work..
I s there any other alternate to do the same
Thanks

Yes it is the error..We cant use as many charecteres as our wish in one line in manifest file......I understood the error ...So to overcome this I have to include all the jars to a single file (zip or jar) I am asking will it work properly or any other method to overcome this issue
Thanks

Similar Messages

  • Jtds classpath in executable jar

    how can i point to jtds-1.0.2.jar with classpath in an executable jar
    with just one class file it was this batch file:javac Dbase.java
    java -classpath .;jtds-1.0.2.jar Dbase
    pause

    ok i think i sorted it by making the batch file add a line to the manifest (it writes it anyway but i added Class-Path)
    echo Manifest-Version: 1.0>>MYMANIFEST.MF
    echo Main-Class: %strFileName%>>MYMANIFEST.MF
    echo Class-Path: . jtds-1.0.2.jar>>MYMANIFEST.MF
    echo Created-By: 1.5.0 (Sun Microsystems Inc.)>>MYMANIFEST.MFthe best source i found was this http://mindprod.com/jgloss/jar.html (right at the bottom of the page)
    that double clickable exe is nifty too, my m8s does that automatically cos its an executable but mine doesnt work like that even if i do open-with =S
    oh well, i just use batches neway =P

  • Setting classpath to execute jar file.

    I have dependency jar files to execute my jar file.
    set classpath=./lib/tpc.jar;./lib/jxl.jar;
          ./lib/log4j-1.2.15.jar;./lib/logSys.jar;
    java -jar ./lib/tpc.jar %1java -jar seems not taking classpath environment variables and showing error as
    Exception in thread "main" java.lang.NoClassDefFoundError:
    com/sys/logger/LogManager
            at utility.tpc.generate.Tpc.generate(Unknown Source)
            at utility.tpc.generate.Tpc.main(Unknown Source)The below one works, but I dont want to give all jar files along with java command and to make complicate.
    java -cp "./lib/tpc.jar;./lib/jxl.jar;./lib/log4j-1.2.15.jar;./lib/logSys.jar;"
             utility.tpc.generate.Tpc %1Is there a way to make first one to work ? Will adding "Class-Path:jxl.jar,log4j-1.2.15.jar,logSys.jar" in my manifest file make it work ?

    baskark wrote:
    I have dependency jar files to execute my jar file.
    set classpath=./lib/tpc.jar;./lib/jxl.jar;
    ./lib/log4j-1.2.15.jar;./lib/logSys.jar;
    java -jar ./lib/tpc.jar %1java -jar seems not taking classpath environment variables and showing error as
    Exception in thread "main" java.lang.NoClassDefFoundError:
    com/sys/logger/LogManager
    at utility.tpc.generate.Tpc.generate(Unknown Source)
    at utility.tpc.generate.Tpc.main(Unknown Source)The below one works, but I dont want to give all jar files along with java command and to make complicate.
    java -cp "./lib/tpc.jar;./lib/jxl.jar;./lib/log4j-1.2.15.jar;./lib/logSys.jar;"
    utility.tpc.generate.Tpc %1Is there a way to make first one to work ? Will adding "Class-Path:jxl.jar,log4j-1.2.15.jar,logSys.jar" in my manifest file make it work ?The jar command is specified to work as you have shown. That is, when you use "java -jar..." the system or command line classpath is ignored. The only classpath that can be used with "java -jar..." is the Class-Path in the manifest. You need to separate the different paths using space characters, not ; or : and the paths need to be relative to the jar file. (I am not sure if "./" will work and it is not needed to specify relative to the jar file.)
    Edited by: atmguy on Dec 14, 2009 8:42 AM

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

  • Executable Jar files with Oracle drivers and Oracle classes

    I have a program which works perfectly that is used to do file
    maintenace on an oracle table. Now I am ready to make this into
    an executable jar file. I know how to do this, but my problem is
    now how do I get the Oracle classes into my jar? I think they
    are all in classes12.zip, but just adding classes12.zip into the
    jar doesnt work. I still get an error when running the program
    that says it can't find oracle.jdbc.drivers.oracledriver.
    You can use the jar command to add all classes in a directory,
    but this doesnt work either.
    Has anyone out there ever done this? Please help if you know how
    to do this. How do you put the oracle classes into you
    executable jar file?
    Wah!!!

    Me again. I forgot to mention that I am only using Java. We
    don't have Oracle forms or jdeveloper. This is just straight
    java. Everything worked until I tried to executable jar creation.

  • Adding a jar to the classpath of an executable jar (mixing -jar and -cp)

    Hello,
    frankly I hesitated over posting this to "New to Java"; my apologies (but also, eternal gratefulness) if there is an ultra-simple answer I have overlooked...
    I integrate a black-box app (I'm not supposed to have the source) that comes packaged as an executable jar (with a Manifest.MF that specifies the main class and a bunch of dependent jars), along with a few dependent jars and a startup script. Long story short, the application code supports adding jars in the classpath, but I can't find a painless way to add a jar in its "classpath".
    The app's "vendor" (another department of my customer company) has a slow turnaround on support requests, so while waiting for their suggestion as to how exactly to integrate custom jars, I'm trying to find a solution at the pure Java level.
    The startup script features a "just run the jar" launch line:
    java -jar startup.jarI tried tweaking this line to add a custom jar in the classpath
    java -cp mycustomclasses.jar -jar startup.jarBut that didn't seem to work ( NoClassDefFound at the point where the extension class is supposed to be loaded).
    I tried various combination of order, -cp/-classpath, using the CLASSPATH environment variable,... and eventually gave up and devised a manual launch line, which obviously worked:
    java -cp startup.jar;dependency1.jar;dependency2.jar;mycustomclasses.jar fully.qualified.name.of.StartupClassI resent this approach though, which not only makes me have to know the main class of the app, but also forces me to specify all the dependencies explicitly (the whole content of the Manifest's class-path entry).
    I'm surprised there isn't another approach: really, can't I mix -jar and -cp options?
    - [url http://download.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html]This document (apparently a bible on the CLASSPATH), pointed out by a repited forum member recently, does not document the -jar option.
    - the [url http://download.oracle.com/javase/tutorial/deployment/jar/run.html]Java tutorial describes how to use the -jar option, but does not mention how it could play along with -cp
    Thanks in advance, and best regards,
    J.
    Edited by: jduprez on Dec 7, 2010 11:35 PM
    Ahem, the "Java application launcher" page bundled with the JDK doc (http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html) specifies that +When you use [the -jar] option, the JAR file is the source of all user classes, and other user class path settings are ignored+
    So this behavior is deliberate indeed... my chances diminish to find a way around other than specifying the full classpath and main class...

    I would have thought that the main-class attribute of the JAR you name in the -jar option is the one that is executed.Then I still have the burden of copying that from the initial startup.jar's manifest. Slightly less annoying than copying the whole Class-path entry, but it's an impediment to integrating it as a "black-box".
    The 'cascading' behavior is implicit in the specification
    I know at least one regular in addition to me that would issue some irony about putting those terms together :o)
    Anyway, thank you for confirming the original issue, and merci beaucoup for your handy "wrapper" trick.
    I'll revisit the post markers once I've actually tried it.
    Best regards,
    Jérôme

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

  • Executable JAR using JDeveloper

    Hi,
    I created a very small Desktop Application using JDeveloper.
    What I want to do is to create an executable JAR file. I mean, is there any option in this tool like the one in Eclipse. Once executable JAR is created, I must be able to run it just by double clicking the JAR file.
    So, can some1 please help me with the steps ?
    JDeveloper : 11.1.1.6.0

    For executable jar you will need to add:
    Main-Class: your_package.YourClassto META-INF/MANIFEST.MF file inside jar.
    I don't think that JDeveloper support custom manifest files so you can modify this content after jar creation(for example, with some zip/rar/7z tool)
    Also, if your app require some additional jars, then you will need to add this line to manifest:
    Class-Path: additional.jarDario

  • Executable Jars and their Classpath

    I have made a java application that takes requires several libraries to run. I am using netbeans 4.0 but have reached the stage where I'd like it to become a standalone application.
    I have editted the projects properties in netbeans to use the correct libraries for compilation and set the correct arguments to run it. It runs fine in netbeans. However, when i try to execute the jar file that netbeans generates with the command...
        java -jar  PeerPressure.jari get the error...
      Exception in thread "main" java.lang.NoClassDefFoundError: net/jxta/pipe/PipeMsgListenerI have tried to modify the manifest.mf file to (it has 2 enters at the end)....
    Manifest-Version: 1.0
    X-COMMENT: Main-Class will be added automatically by build
    Main-Class: Main
    Class-Path: /lib/jxta.jar /lib/bcprov-jdk14.jar /lib/javax.servlet.jar /lib/log4j.jar /lib/org.mortbay.jetty.jarbut i get the same error. I've also tried the command...
      java  -classpath \lib\jxta.jar;\lib\log4j.jar;\lib\bcprov-jdk14.jar; -jar PeerPressure.jarI'm not sure what else i could try. I've already looked through loads of tutorials and forums posts but still havent got any further. Any help would be great.
    Cheers

    Tried it and still no luck :(
    I tried executing the jar that netbeans 4.0 generates with a project that doesnt require the classpath to be set and that works fine. Also, looking at the stack trace, I've noticed that the executable jar file that i'm having problems with does actually execute. But when it reaches a class that implements the PipeMsgListener it stops.
    C:\Documents and Settings\Scottie\PeerPressure\dist>java -classpath ..\lib\jxta.
    jar;..\lib\log4j.jar;..\lib\bcprov-jdk14.jar;. -jar PeerPressure.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: net/jxta/pipe/PipeMsg
    Listener
            at java.lang.ClassLoader.defineClass0(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$100(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)
            at peerpressure.Main.main(Main.java:26)i get the same error when i try
    java -jar PeerPressure.jarMy first thought was that the class that implements the PipeMsgListener was at fault. But when i run the project through netbeans it works fine!
    Not sure whats going on really. Does anyone know how to find out the command that netbeans is using to execute a project? If i could find out what it is i could use it to execute my jar.
    cheers :)

  • Download and execute jars without using javaws

    Hi
    I need to download and execute jars from remote computer. I hava jnlp file, but I strongly need to execute jars without using java web start.
    What is the best way to do this task?
    Thanks in advance :)
    Edited by: joekidd on Aug 3, 2009 5:55 AM

    joekidd wrote:
    The easiest the best:)The easiest way is to hire the programmers who made the Jar, to consult on your behalf to install the program, or advise on its installation. BTW - you said earlier.. "strongly need to execute jars without using java web start." Why? What advantage does that provide?
    So I download needed jars, add them to classpath and run my application (I get all information from jnlp file and pass them to vm and my application).
    But following exception occurs "Exception in thread "main" java.lang.NoClassDefFoundError: javax/jnlp/ServiceManager". What should I do?Get in contact with those programmers, because this app. is dependant(1) on functionality that is only available to web start apps.
    (1) Unless they put that call in there, just to ensure no one can run the app. outside web start. ;-)

  • I dont see the point of using Ant Build compared to executable Jars?

    I always think that to complete a project you successfully build it. And i thought that building is done automatically if you create an executable JAR? So what is ANT for?
    Arent Executables is the same as building your project?

    paulcw wrote:
    They are all unnecessary for a single person doing small projects (although often still necessary).I assume you meant "(although often still useful)".
    And furthermore you may find that the vast majority of your time programming professionally isn't the programming, but just managing these other aspects.It is a good day for me when that is not the case ;-)
    There should be a class in university: "industrial practices". It would have little or no CS theory but all the stuff that you learn the first year on the job (often painfully).The company I work in really likes to hire young developers, which often means that they come right from school (gladly, we have some good IT-centric schools in the area). They usually get some introduction in some of these aspects in school (usually mostly version control, bug tracking and a little bit of automated builds). But even if they heard about them, used them for a simple project and get the general idea, they still don't believe them to be necessary until they see what a pain in the back it can be not to have all that in a medium-sized project.

  • Why -jar option used to install a software which is in executable jar file?

    Hi all,
    i have a query, i have a generic installer which is used to install the oracle weblogic 10.3 software in unix platform(i.e., which is in .jar extension) which is executable jar file.
    To install this software which have to use -jar option to install
    java -jar net_server<version>_generic.jar
    my question that why we use -jar option to install or to extract the software
    can any one clarify my doubt...
    thanks in advance
    abhi
    Edited by: sumanth_abhi on Jan 27, 2009 11:50 PM

    According to the Jar Guide (http://java.sun.com/j2se/1.4.2/docs/guide/jar/jarGuide.html)
    Executable Jar Files
    On Microsoft Windows systems, the Java 2 Runtime Environment's installation program will register a default association for Jar files so that double-clicking a Jar file on the desktop will automatically run it with javaw -jar. Dependent extensions bundled with the application will also be loaded automatically. This feature makes the end-user runtime environment easier to use on Microsoft Windows systems.
    The Solaris 2.6 kernel has already been extended to recognize the special "magic" number that identifies a Jar file, and to invoke java -jar on such a Jar file as if it were a native Solaris executable. A application packaged in a Jar file can thus be executed directly from the command line or by clicking an icon on the CDE desktop.
    Despite that every JAR file can be executed as a program if and only if the META-INF/Manifest.mf contains the Main-Class tag. This done through java -jar jarfile.jar
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to create executable jar in eclipse using linking in compiler

    Hi,
    I have a project in Eclipse. I wrote already an ant build file for creating an executable jar which includes all project files.
    Now I want to create a second executable jar which is a subset of the project (a limited number of classes are necessary).
    I have a main class and I was looking for a way to generate a jar file which includes the main class and all the depending classes.
    Is there a way to do it? With ant or with another tool?
    Is it possible to compile a project given a main class, and include all depending classes?
    Regards,
    Biebel
    Edited by: biebel1975 on Jan 7, 2009 10:21 AM

    biebel1975 wrote:
    Some more information:
    When I compile all the classes, the jar file is +/- 3.5Mb inclusive the server side logic.
    The subproject I want to build, should be less then 1Mb (Only some screens and beans, no business logic ((only +/- 10% of the projects code) )).
    My question is: How can I create a executable jar with only the necessary class files which depends on the main class. (Linked with the imports).
    Is there a tool to do that? Can it be done with an ANT script? If so, how does the script looks?
    What are you talking about?
    You already said that you are using Ant.
    Ant uses script files.
    Since you have one with X items in it and you want something new with X-Y items in it the obviously it would make sense to construct an ant script that does less than the other ant script.
    The following provides a huge amount of information about Ant.
    [http://ant.apache.org/resources.html]
    Other than that no one can tell you want your Ant script will look like except that it will do less than the one that you already have.

  • Classpath is not working for executable jar file

    I have created executable jar file using following command where manifest file contains Main-Class and Class-Path entries.
    jar cvfm app.jar META-INF/* lib/* *.class
    So here app.jar contains my external jar's in lib directory
    but when I move app.jar to another directory, it's doesn't get my external files.
    I'm not getting this problem as these jar's are in app.jar
    class-path entry in manifest file:
    Class-Path: lib/abc.jar lib/xyz.jar
    Pls help me where it is getting fail?
    Thanks in advance,
    Vikas

    Java doesn't handle jars within jars. Your library jars need to be outside of the executable jar as in
    dist - main.jar
          - lib  -  lib1.jar
                 -  lib2.jar

  • Making executable jar file the database using JTable

    How can i make an executable jar file if I will use a JTable on my database?Can you tell me how?
    Thank you !!

    dantte wrote:
    in truth, ur question is not clear enough. elaborate on what exactly it is u want, and what u ar truin to achieve.You don't seem to know enough English, let along Java, to be answering questions here.
    %

Maybe you are looking for

  • Address Book Sorting

    Using BES, Curve 8330 on 4.5 and Outlook 2003 Exchange... Any time I enter an address in my Curve, it will sync perfectly with Exchange and sync with my outlook contacts. However, every time, it will sort by last name, first name. I've told the BB de

  • Send-Mailmessage Query

    Hi All Am trying to send an email with attachment in body (HTML format ) which is coming fine without any issue but i need to add few test message in body, ...like .. HI All please see the below report or something The attachment is the output of the

  • "Acct group RENT uses internal no.assignment; leave blank

    Hi experts, Iu2019ve created a vendors account group RENT with number range u201C06u201D (0600000001 u2013 0699999999). But when creating the vendor Ivan15, I get the following error:  u201CAcct group RENT uses internal no.assignment; leave blank Mes

  • EP 6.0 SP9-- SP16 Upgrade error-"Unable to add account #0 to group"

    Hello,      I am working on EP 6.0 SP9 Patch8.(Stand alone Java Only) When I am trying to upgrade it SP 16, I am getting following error: ERROR 2006-08-02 18:24:58 FSL-01006 Unable to add account <#0> to group <#1>. <#2> ERROR 2006-08-02 18:24:58 MUT

  • Unknown Fault (with example file)

    One of my collection columns gets mixed with another collection. I remove all screens, visuals and collection except  the mixed collection and visuals linked with that collection. But I get still columns from a collection what is already removed from