How to create an executable jar-file ?

T

tony lincoln

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
 
J

Jacob

tony said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top