The Artima Developer Community
Sponsored Link

Java Answers Forum
how do i make executeable jar files

2 replies on 1 page. Most recent reply: Jul 23, 2002 7:30 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Trelan Hylton

Posts: 6
Nickname: teejay
Registered: Jul, 2002

how do i make executeable jar files Posted: Jul 21, 2002 3:25 PM
Reply to this message Reply
Advertisement
i am almost complete in a four months intense java course. i am able to create full aplications such as multiclient/server chatrooms, database systems and notebooks but i don't know how to put it all together so that someone simply clicks on an icon and enter the application. someone please help me. by the way is there a free software available that would allow me to do that?


Jay Kandy

Posts: 77
Nickname: jay
Registered: Mar, 2002

Re: how do i make executeable jar files Posted: Jul 23, 2002 6:57 PM
Reply to this message Reply
Heres how to make executable jars: Firstly, create a manifest file say, manifest.mf. Edit the file thus:

Manifest-Version: 1.0
Main-Class: com.kandy.foo.Bar

where Bar is a public class with main method. Thats what the Main-Class should point to. That done, jar your classes or packages and this manifest file with jar command. Its at $JAVA_HOME/bin:
jar -cvfm myJar.jar manifest.mf MyClass.class or
jar -cvfm myJar.jar manifest.mf com if you had com.kandy.foo package. That creates myJar.jar in the current folder.

You can execute that like this:
java -jar myJar.jar

If you dont like typing, create a shell file or a batch file, use a command like the above line in the file. Click/run it.

Sincerely,
Jay

PS: Matt Gerrans posted an article on how to associate .jars with double click on windows (or so I learnt) You might want to search this forum (or check with him)

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: how do i make executeable jar files Posted: Jul 23, 2002 7:30 PM
Reply to this message Reply
Yes, if you are doing this for the Windows platform, search this forum for a detailed explanation of setting that up, as Jay suggests.

Furthermore (I don't know if I mentioned this before), in Win-NT/2K/XP you can use the commands ASSOC and FTYPE to set up the file associations and types from the command line (which also makes easy to script). Type either of these two commands with a /? parameter to get some help. Once you have used these to set up jar and class files, you can run the program just by typing the name of the file (without the extension, even, if you also set up your PATHEXT environment variable to include .JAR and .CLASS). Then, when you set up shortcuts (or icons), or when you double-click in Explorer, your programs will run as if they were native Windows programs. By the way, for GUI apps, you'll probably want to use javaw, not java, so the spurious console window doesn't appear.

In addition to Java programs, I have set up my environment this way for Python scripts. It changes this:
c:\Python22\Python e:\code\python\HexDumper.py javac.exe
to
HexDumper javac.exe

Flat View: This topic has 2 replies on 1 page
Topic: Calling Methods by name Previous Topic   Next Topic Topic: drop down menu

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use