Executable Jar Trouble

Hello everyone,
I am creating an executable jar with this command:
jar cmf CarmaFrame.mf CarmaNew.jar *.*
The contents of the manifest file (CarmaFrame.mf ) are:
Manifest-Version: 1.0
Class-Path: j.jar
Main-Class: CarmaFrame.class
This creates an executable jar in the directory that contains all of the files. It executes fine when double clicked in windows xp.
If I move the newly created jar file to my desktop and try to double click it, I get this error:
could not find the main class. program will exit.
None of my java files are using packages. Any ideas on why I am having this problem?
BTW, the j.jar file is a dependent jar file that does show it is in the CarmaNew.jar file when using the command:
jar tf CarmaNew.jar
Thanks,
Brandon

Packaging a jar within an executable jar:
http://forum.java.sun.com/thread.jsp?forum=22&thread=405160&tstart=0
http://forum.java.sun.com/thread.jsp?forum=22&thread=505248&tstart=0&trange=15
http://forum.java.sun.com/thread.jsp?forum=4&thread=432114&tstart=0

Similar Messages

  • Problem running my program only after making an executable jar...

    Hi everyone,
    I am having trouble running my program after creating an executable jar. The program runs fine until
    it is supposed to open a specific JFrame. I get the following error message as soon as the frame tries
    to open:
    Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.apache.xerces.parsers.SAXParser.<init>(Lorg/apache/xerces/xni/parser/XMLParserConfigurat
    ion;
    Has anyone ever seen this before?
    The strange thing is, this does not happen when I build and run the project under Eclipse.
    Any help or tips would be appreciated!
    Chris

    Roosh wrote:
    The strange thing is, this does not happen when I build and run the project under Eclipse.
    Any help or tips would be appreciated!Make sure you are using the same version of Java as you use with Eclipse.

  • 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

  • A stubborn executable jar: refuses to execute

    i'm trying to make an executable jar to be activated by double-clicking (on a Windows system).
    trying it on a simple example works well end-to-end.
    trying it on my app i get only partial success. when i run it using:
       java -jar lipidia-1.1.0.jar everything runs well.
    but when i doubleclick it (or invoke it from the command prompt as: lipidia-1.1.0.jar) i get the following error:
    Exception in thread "main" java.util.zip.ZipException: The system cannot find the file specified
            at java.util.zip.ZipFile.open(Native Method)
            at java.util.zip.ZipFile.<init>(ZipFile.java:112)
            at java.util.jar.JarFile.<init>(JarFile.java:117)
            at java.util.jar.JarFile.<init>(JarFile.java:55) now, my manifest is as follows:
    Manifest-Version: 1.2
    Ant-Version: Apache Ant 1.5.3
    Created-By: 1.4.1-b21 (Sun Microsystems Inc.)
    Main-Class: org._3pq.lipidia.ui.Lipidia
    Class-Path: lib/jgrapht-0.5.1.jar lib/jfreechart-0.9.15.jar lib/jcommon-0.9.0.jar lib/bsh-1.3b2.jar the folder lib does contain the jars as needed.
    now, my app tries to write files. can it be that it fails because the output is directed to the jar instead to the file system? if so, any trick to avoid that? ideas? saves?
    thanks,
    barak

    problem solved.
    for windows to open executable .jar files upon double-click there should be a file association such as:
    "C:\progs\j2sdk1.4.1_01\bin\java.exe" -jar %1
    right?
    WRONG!!!
    beloved windows often has folder names with white-space (such on the desktop):
    C:\Documents and Settings\... the above association will NOT always work properly because of the %1, that doesn't like filenames with spaces. the correct way of making the association is:
    "C:\progs\j2sdk1.4.1_01\bin\java.exe" -jar "%1"
    now, if you find this post and it saved you from trouble, please drop a line in this thread.
    will be cheerful to know that at least someone benefited from my wasted time... ;-)

  • Question about Executable JAR Files

    Is it possible to make an executable JAR file that has all of the *.class files, all of the *.jar archives used, etc. packaged into one file that doesn't need these external files within the same directory? I've been having a ton of trouble finding the answer to this. (If it's blatantly obvious, please forgive me.)

    Hello,
    I went through the same thing recently. Here is a piece of the build file I use:
    <project name="MyProj" basedir="." default="main">
        <property name="src.dir"     value="src"/>
        <property name="build.dir"   value="build"/>
        <property name="classes.dir" value="${build.dir}/classes"/>
        <property name="jar.dir"     value="${build.dir}/jar"/>
        <property name="main-class"  value="MyProj.Main"/>
        <property name="lib.dir"     value="lib"/>
        <path id="classpath">
            <fileset dir="${lib.dir}" includes="**/*.jar"/>
        </path>
        <target name="compile">
            <mkdir dir="${classes.dir}"/>
            <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
        </target>
        <target name="jar" depends="compile">
            <mkdir dir="${jar.dir}"/>
            <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
              <zipfileset src="lib/commons-codec-1.3.jar"/>
              <zipfileset src="lib/commons-fileupload-1.1.1.jar"/>
              <zipfileset src="lib/commons-httpclient-3.0.1.jar"/>
                <manifest>
                    <attribute name="Main-Class" value="${main-class}"/>
                </manifest>
            </jar>
        </target>
        <target name="main" depends="clean,run"/>
    </project>Note the <zipfileset> tags that contain the .jars.
    There are, however, many good reasons to not do this. Some were already mentioned, another is in the case of update external libraries, you might not want to rebuild your whole project, replacing a jar may be easier.
    Good luck,
    -Sam

  • Links not working in executable jar

    I have a problem with my java application
    html and images files do not work in executable jar
    though the application works normally
    I tried some suggestion but I received an exception thread indicating problem at
    ImageIcon iChing = new ImageIcon(imageURL);
    Please could you help me thank you so much
    here is the class
    public class Main extends JFrame
    * objects required for the GUI: JFrame,JLabel, JButton, ImageIcon, JPanel,
    * Dimension
    private static final long serialVersionUID = 1L;
    JButton jbEnter;
    ImageIcon iChing, logo;
    JPanel buttonPanel, ImagePanel;
    JLabel jlbIching;
    Dimension dim;
    URL imageURL;
    File fileName;
    // Class constructor to create the GUI
    public Main()
    Container container = getContentPane();
    URL imageURL = this.getClass().getClassLoader().getResource("src/myFiles/iching.gif");
    ImageIcon iChing = new ImageIcon(imageURL);
    jlbIching = new JLabel(iChing);
    // button to go to the Title class
    jbEnter = new JButton("Enter ");
    jbEnter.setBorderPainted(false);
    jbEnter.setFont(new Font("Edwardian Script ITC", Font.BOLD, 42));
    jbEnter.setBackground(new Color(0, 0, 50));
    jbEnter.setForeground(Color.YELLOW);
    jbEnter.addActionListener(new ActionListener() {
    // method to render the current frame invisible and trigger the
    // Welcome Menu
    public void actionPerformed(ActionEvent e)
    setVisible(false);
    // this line does not work...............
    new Title();
    } // close the actionPerformed(ActionEvent e) Method
    }); // close the addActionListener(new ActionListener() method
    // Panel holding the decorative image and Button
    ImagePanel = new JPanel();
    ImagePanel.add(jlbIching);
    ImagePanel.setBackground(new Color(0, 0, 50));
    buttonPanel = new JPanel();
    buttonPanel.add(jbEnter);
    buttonPanel.setBackground(new Color(0, 0, 50));
    // setting up of the panels position
    container.add(ImagePanel, BorderLayout.CENTER);
    container.add(buttonPanel, BorderLayout.SOUTH);
    dim = Toolkit.getDefaultToolkit().getScreenSize();
    dim.width = dim.width / 2 - 300;
    dim.height = dim.height / 2 - 250;
    setBounds(dim.width, dim.height, 400, 400);
    setSize(600, 500);
    setResizable(false);
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //To set the icon for the application. Top left hand corner.
    //this.setIconImage(Image);
    setIconImage(new ImageIcon("src/myFiles/ichingRose.gif").getImage());
    } // close the Constructor
    * the main method for the program.
    * @param args
    * The command-line arguments.
    public static void main(String[] args)
    new Main();
    } // close the main method
    } // close the Main class

    Thank you very much for your quick reply and really hope you can help me a little more
    it's so frustrating
    I do not really know about the relative path but here is my xml file
    <?xml version="1.0" encoding="UTF-8" ?>
    <project default="jar">
    <!-- Compile and zip the source code into a jar -->
    <target name="jar">
    <!-- Make the folders we'll need -->
    <mkdir dir="ant"/>
    <mkdir dir="work"/>
         <mkdir dir="ant/myFiles"/
    <!--
    Compile all the .java files into .class files
    debug = yes Include debug information in the .class files
    destdir Where to put the .class files
    source and target Use Java version 1.6.0_06
    -->
    <javac
    debug="yes"
    destdir="ant"
    source="1.6"
    target="1.6">
    <!-- Folders that have trees of .java files to compile -->
    <src path="src"/>
    </javac>
         <copy todir="ant/myFiles"><fileset dir="src/myFiles"></fileset></copy>
    <!--
    Zip files together to make a jar
    jarfile Where to make the .jar file, overwrite something there
    basedir Find the files to zip in the jar here
    -->
    <jar
                   jarfile="work/BookOfChanges.jar"
    basedir="ant"
    >
    <!-- Write a manifest inside the jar -->
    <manifest>
    <!-- The class Java will run when the user double-clicks the jar -->
    <attribute name="Main-Class" value="iChing.Main"/>
    </manifest>
    </jar>
    </target>
    </project>

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

  • 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

  • Class not found error while executing jar file

    I have written a java code in which i am connecting to database....when i run the class file using......java class_filename it works........
    but when i run the jar file using .......java -jar jar_name ...yi gives me the error as 'Class not found'......
    can anybody help me please......
    Thanks and Regards,
    Siddhesh

    that class is part of jar file.....in classpath i have included zip files for jdbc ...to get databse connection.....and the jar being executed ................still it gives the error ClassDefnotfound which i think is due to database connection problem.....the exception is raised while.....
    Class.ForName("Driver_name").newInstance();/ This driver is present in zip files that i have added in classpath....
    above statement doesn,t giv error while i execute the class file............but exception while executing jar file only..
    Thnaks and regards,
    siddhesh

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Executable JAR file: Could not find the main class.

    Hello,
    I have a problem with making an executable JAR file.
    I have written a JAVA program that consists of five different classes of which User.java is the main class and I have saved a text document with Main-Class: User and a blank line after that.
    If I try:
    jar cmf MainClass.txt User.jar User.class Beheerder.class Operator.class Manager.class MaakVisueelSchema.class
    it makes a executable jar file which actually works! :)
    But when the Operator class trys to open the MaakVisueelSchema class the screen stays blank.
    I can run MaakVisueelSchema with java MaakVisueelSchema.
    So I tried to make an executable JAR that consists only of MaakVisueelSchema, the same way as I did for User:
    Main-Class: MaakVisueelSchema
    jar cmf MainClass.txt MaakVisueelSchema.jar MaakVisueelSchema.class
    Then I get the error message:
    Could not find the main class. Program will exit.
    from the Java Virtual Machine Launcher.
    The big difference between MaakVisueelSchema and the other classes is that MaakVisueelSchema contains a PaintComponent method and an ComponentListener. Is it possible that one of those creates the error?
    Can anyone help me with this problem?
    Thanks in advance!
    Bye!

    Yes,
    I tried:
    jar xvf MaakVisueelSchema.jar
    and it returns:
    META-INF/
    META-INF/MANIFEST.MF
    MaakVisueelSchema.classN/G. You need to manually create a manifest file in a text editor, have it point to your main class, and enter it in your jar command as an argument.

  • How can I add image files to a executable jar file ?

    Could you tell me how can I add image files to executable jar file ?
    package structure:
    ../com/Main.class
    ../images/..

    Please don't cross post, and read this
    http://forum.java.sun.com/thread.jsp?forum=31&thread=271751
    I've answered the question in the New To Java thread.

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

  • FileWriter in executable jar

    I have a problem to read/write textfiles inside an executable jar.
    The problem exists when the files are included in the jar.
    E.g. writing to files outside the jar is fine and currently my solution is to keep them that way.
    At first I also had a problem pointing to images in the
    jar-file but it worked with something like the following:
    img=java.awt.Toolkit.getDefaultToolkit().getImage(getClass().getResource("example.gif"));
    I tried the same approach to the FileReader like this:
    FileReader fr=new FileReader(getClass().getResource("example.dat").toString());
    The application compiles fine but does not find the file.
    Please share your expertise with me.

    You have to use external files or play with the java.util.jar package - there is not support for writing things directly to a jar in the java.io package.

  • Large project in JBuilder 2007... How do I create an executable JAR?

    First, I've googled quite a bit and keep getting thiings about "Jbuilder Application Wizard", etc... Well, I don't see any "wizard" menu in the version of JBuilder I'm using!
    I'm using JBuilder 2007 Enterprise edition, however it's a trial version apparently. I'm not sure if that matters, and perhaps the functionality was taken out with the trial version..
    Anyway, the issue is that I have a multi class (with one main function) program that I want to run (it's a command line based application) as an executable JAR file. The program uses LOTS of include statements including quite a few custom libraries ("external JARs") that I had to import.
    Basically I want the application to do exactly what it does now when I hit the ol' "RUN" button. Except I want to be able to run it from a batch file with "java -jar (or whatever) myProgram".
    Anybody have any experience with this type of thing?

    OK, here's what I've got:
    I've got a jar file that contains:
    1. a folder "importQD"
    2. a folder called META-INF
    3. a .classpath file
    4. a .project file
    Inside the importQD folder are my three .class files that are the classes I created myself.
    Inside the META-INF folder is the MANIFEST.MF file which looks like:
    Manifest-Version: 1.0
    Main-Class: importQD.ImportQDInside the .classpath file we have:
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
         <classpathentry kind="src" path=""/>
         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
         <classpathentry kind="lib" path="C:\Programs\CMQualityDocumentImport\CMUploadInterface83.jar"/>
         <classpathentry kind="lib" path="C:\Programs\CMQualityDocumentImport\DBCon.jar"/>
         <classpathentry kind="lib" path="C:\Programs\CMQualityDocumentImport\SENAeMail.jar"/>
         <classpathentry kind="lib" path="C:\Programs\CMQualityDocumentImport\SENAFileHandler.jar"/>
         <classpathentry kind="output" path=""/>
    </classpath>NOTE: All of the paths point at the .jar files as they are located on the machine the final version will be running on.
    Inside the .project file we have:
    <?xml version="1.0" encoding="UTF-8"?>
    <projectDescription>
         <name>importOldQD</name>
         <comment></comment>
         <projects>
         </projects>
         <buildSpec>
              <buildCommand>
                   <name>org.eclipse.jdt.core.javabuilder</name>
                   <arguments>
                   </arguments>
              </buildCommand>
         </buildSpec>
         <natures>
              <nature>org.eclipse.jdt.core.javanature</nature>
         </natures>
    </projectDescription>Now, it would make sense to me that this should be all good to go, and that I should be able to run this via a command line now. When I try
    java -jar importQD.jar I get a ton of various errors such as "Exception in thread "main" java.lang.UnsupportedClassVersionError: importQD/importQD (unsupported major.minor version 49.0) + a nice stack trace with a bunch of java.lang and java.net references.
    What am I doing wrong?

Maybe you are looking for

  • Closed Captioning Window slow to open

    We have a team member using CP7 on a Win7 machine having a delay when he opens the closed captioning window.  It can take up to 10 seconds for the window to open.  We just put him on someone elses machine and it didn't do that even when logged in wit

  • I am unable to open my flash drive

    i was using my flash drive, but then when i moved it from a windows based system to my macBook Pro it is no detecting the flash drive.

  • Lightroom and PS serial numbers

    I just bought a new laptop. I want to download lightroom and photoshop. All I have records of is the upgrade serial numbers. No record of the original serial numbers. How can I download, or how can I find the original serial numbers? HELP!!

  • Trouble finding files

    I let 3 or 4 albums from Photoshop.com to transfer (by default/do nothing) to Revel.com. Aside from that, I put an album (1308WI) with 34 photos up on Revel.com. When logging on to Revel, I expected to see the old albums and the new one. The newly-up

  • I can't open Creative Cloud in Windows 7. I get nothing -- not even the blank window.

    It's worked fine until yesteday. Initially it only opened the white window and I followed many suggestions on this forum, renamed OOEB, used CC Cleaner, reinstalled, deleted opm.db. Now it is worse - it will not even open the blank window. I get the