Results 1 to 7 of 7
  1. #1
    silverglade is offline Senior Member
    Join Date
    Feb 2009
    Posts
    182
    Rep Power
    6

    Default Trying to make a jar file double click/run from desktop

    Hi, I am having trouble making an executable jar file that I can email someone and have them run it on their desktop. The app has a gui window that will pop up, very simple app.

    I did this on the command line


    jar cf PushCounter.jar Pushcounter.class PushCounterPanel.class <enter key>

    and it made a jar , but when I double click it, it doesn't make the GUI popup window


    then I tried jar cf PushCounter.jar * <enter key> to include all the files in the directory relating to the program and no good.

    Any help would be great. thank you. Derek

    I posted this also here Java applet won't display in firefox (Applets forum at JavaRanch)

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    I have found making jar files a PITA. One thing I usually have problems with is the manifest file. Pointing out where you are going wrong over the net is nigh impossible as we are not there to see what you are doing. Are you reading a Jar tutorial? I suggest you read it and follow it very VERY carefully. If you skip or make a mistake in any of the steps the jar file will not be created correctly.

  3. #3
    Solarsonic is offline Senior Member
    Join Date
    Mar 2011
    Posts
    261
    Rep Power
    4

    Default

    Create a new text file named manifest. Put in the following:

    Java Code:
    Main-Class: CLASSHERE
    Put the name of your main class (the one with the main method) in place of "CLASSHERE".

    Now open command prompt, navigate to the directory of your class files and manifest file, and enter this:

    Java Code:
    jar cvfm program.jar manifest.txt *.class

  4. #4
    silverglade is offline Senior Member
    Join Date
    Feb 2009
    Posts
    182
    Rep Power
    6

    Default

    edit I will try the above thanks

    Ok I made the jar file with the manifest with the correct contents. But the jar doesn't run on the double click. Here is the message from the command line upon making the jar.

    C:\JAVA_PROGRAMMING_CODE\code1\pushcounter>jar cvfm PushCounter.jar Manifest.txt
    *.class
    added manifest
    adding: PushCounter.class(in = 657) (out= 431)(deflated 34%)
    adding: PushCounterPanel$1.class(in = 199) (out= 152)(deflated 23%)
    adding: PushCounterPanel$ButtonListener.class(in = 1084) (out= 572)(deflated 47%
    )
    adding: PushCounterPanel.class(in = 1527) (out= 790)(deflated 48%)

    C:\JAVA_PROGRAMMING_CODE\code1\pushcounter>



    Contents of my manifest are this below


    Main-Class: PushCounter
    Last edited by silverglade; 05-13-2011 at 03:12 AM.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Did you end the manifest with a blank line?

    db

  6. #6
    silverglade is offline Senior Member
    Join Date
    Feb 2009
    Posts
    182
    Rep Power
    6

    Default

    Thank you. I just ended the manifest.txt with a few empty carriage returns to make a few blank lines. Saved it, and recompiled. Here is the log of what I did at the command prompt, thanks for helping. I want to get this running so bad LOL. It just won't run. Notice the "unable to load manifest info" when I even try to run it at command prompt.



    C:\JAVA_PROGRAMMING_CODE\code1\pushcounter\classes >jar -cvmf manifest.txt PushCo
    unter.jar *.class
    added manifest
    adding: PushCounter.class(in = 657) (out= 431)(deflated 34%)
    adding: PushCounterPanel$1.class(in = 199) (out= 152)(deflated 23%)
    adding: PushCounterPanel$ButtonListener.class(in = 1084) (out= 572)(deflated 47%
    )
    adding: PushCounterPanel.class(in = 1527) (out= 790)(deflated 48%)

    C:\JAVA_PROGRAMMING_CODE\code1\pushcounter\classes >java -jar PushCounter.jar
    Failed to load Main-Class manifest attribute from
    PushCounter.jar


    C:\JAVA_PROGRAMMING_CODE\code1\pushcounter\classes >

  7. #7
    silverglade is offline Senior Member
    Join Date
    Feb 2009
    Posts
    182
    Rep Power
    6

    Default

    MWAHAHAHAHAHAHAHAHAHAAHHA. I GOT IT TO WOOOORRRKKK. hehehehehh. YES PRAISE GOD. NOW I CAN SHARE MY APPS WITH FRIENDS. ONE CARRIAGE RETURN ONLY DID THE TRICK IN THE MANIFEST, THANK YOU ALL!!! DEREK DD:

Similar Threads

  1. running jar file by double click
    By Himanshu23 in forum AWT / Swing
    Replies: 0
    Last Post: 11-11-2010, 08:24 AM
  2. Replies: 1
    Last Post: 10-30-2010, 06:27 PM
  3. How to make Exe file of desktop application
    By rakesh_n_mehta in forum AWT / Swing
    Replies: 1
    Last Post: 12-12-2009, 01:27 PM
  4. run java application from desktop with double click
    By Rose88 in forum Advanced Java
    Replies: 4
    Last Post: 09-29-2009, 06:32 PM
  5. Run Jar file on double click
    By dhaval.rajput.p in forum New To Java
    Replies: 2
    Last Post: 07-24-2009, 05:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •