Run java program like .exe files

asukai
asukai used Ask the Experts™
on
How can I make a java program to run by double clicking on a icon like .exe files?(so no need to type"java classname")

thanx,

asukai
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi, asukai

if i am not mistakened, when u installed the jdk, it automatically associate the .class file with java already?

if not u can try to create a new file type, .class and has a default action called open
the command for open would be something like java "%1"

=======CoolBreeze=======
== Cool It, the Breeze is here  ==
=====================
Mick BarryJava Developer
Top Expert 2010

Commented:
You need to create an executable jar. This is simply a jar file with the name of the class to run specified in the MANIFEST.
Java Developer
Top Expert 2010
Commented:
eg.
Manifest-Version: 1.0
Main-Class: MyClass
Created-By: 1.3.1_6 (Sun Microsystems Inc.)

Some background on jar files:
http://java.sun.com/docs/books/tutorial/jar/basics/index.html
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Commented:
Beside an executable jar, you may try this as well:
http://www.mpowers.net/executor/

The program helps you to convert jar file to an exe
Distinguished Expert 2018

Commented:
 You can also have a bat file that runs a Java class. Then you only need to double click this batch file.

Commented:
hi
use javaw that ships with the jdk
create a shortcut and give the following as Target for the shortcut
javaw.exe Test where Test is the name of your class u want to execute(specify necessary path)
now if u double click on the shortcut it will run your application
if u have the gui components in application i will show
if u don't have the GUI it won't show u anything
advantage of this over the bat file is that javaw approach won't invoke the console

cheers
RJ

Author

Commented:
Thanx for many answers. Although many of them are gvery good, as I can only choose one person, I'll choose objects to give the points. Thank you all for the answers anyway.
asukai
Mick BarryJava Developer
Top Expert 2010

Commented:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial