How to create an executable jar-file ?

Discussion in 'Java' started by tony lincoln, Jul 16, 2003.

  1. tony lincoln

    tony lincoln Guest

    Dear friends,

    I have to change *.class into *.exe, so my friends who have no too
    much computer experience can use my small program conviniently. It is
    said that one way to do that is to create an executable jar-file. But
    how to create an executable jar-file?

    Excuse me for this simple question.
    Thanks a lot.
    tony lincoln
     
    tony lincoln, Jul 16, 2003
    #1
    1. Advertising

  2. tony lincoln

    Jacob Guest

    tony lincoln wrote:
    > I have to change *.class into *.exe, so my friends who have no too
    > much computer experience can use my small program conviniently. It is
    > said that one way to do that is to create an executable jar-file. But
    > how to create an executable jar-file?


    An "executable jar-file" is a jar file with a manifest
    file specifying the class of your main method.

    What you need to do is as follows:

    o Create the manifest file. It is a text file which
    in your case will contain a single line:
    Main-Class: com.company.main.MyMain
    You can call the file anything you like, for instance
    "myManifest".

    o Build the jar file, for instance:
    jar cmf myManifest myJar.jar *.class
    Providing you are in the directory of your class files
    and your manifest file.
    This will create the myJar.jar file.

    o Test it. On the command prompt do
    java -jar myJar.jar

    If the window manager has its file associations set
    correctly, the myJar.jar is now "executable" so instead
    of the java command above you should be able to just
    doble click its file-entry or desktop shortcut.
     
    Jacob, Jul 16, 2003
    #2
    1. Advertising

  3. And if it hasn't, choose "open with ..." java or javaw

    > If the window manager has its file associations set
    > correctly, the myJar.jar is now "executable" so instead
    > of the java command above you should be able to just
    > doble click its file-entry or desktop shortcut.
    >
     
    Arnaud Berger, Jul 16, 2003
    #3
  4. tony lincoln

    Roedy Green Guest

    On Wed, 16 Jul 2003 10:52:39 +0200, "Arnaud Berger"
    <> wrote or quoted :

    >> If the window manager has its file associations set
    >> correctly, the myJar.jar is now "executable" so instead
    >> of the java command above you should be able to just
    >> doble click its file-entry or desktop shortcut.


    see http://mindprod.com/jgloss/jar.html
    for how to make jars double clickable.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jul 16, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Peters
    Replies:
    0
    Views:
    589
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,734
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,782
    Roedy Green
    Feb 14, 2006
  4. Jason Cavett
    Replies:
    8
    Views:
    624
    Sanjay
    May 16, 2007
  5. Replies:
    0
    Views:
    444
Loading...

Share This Page