Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to create exe file

 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to create a exe file from a jar file?
Actually i want my program to run just by double click.
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An exe will tie you down to the windows platform.

A jar file can be made to launch the application by double clicking it.
Check this out for more details on creating a jar and especially the manifest file
http://java.sun.com/docs/books/tutorial/deployment/jar/
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the link...
Now i am able to run the jar file in command prompt using the command "java -jar *.jar"
But when i double click on the *.jar file nothing is happening...
Whatis that i am missing??
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[qoute]Now i am able to run the jar file in command prompt using the command "java -jar *.jar"

You cannot "run" a jar file that way.
It has to be something like java -jar JarFileName.jar
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah... i mean to say
java -jar FileName.jar
is working...

But not able to run by double clicking
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "not able to run". Do you get any warning dialogs?
What is this application? Is it some GUI stuff?

When you run it using java -jar FileName.jar do you get any stack trace on the console?
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a gui... the program prints a sequence of numbers.


It gives the output... A sequence of numbers.
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anything special should be done to make jar to execute on double click!!??
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ananth Chellathurai wrote:Anything special should be done to make jar to execute on double click!!??

Nothing... just dis play number
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.
The jar file, on double click, is designed to run with javaw by default, which does not have a console window.

To change this, on windows, you can right click the jar file, select open with and choose java (instead of javaw)

Once you set this up, you can double click, and see the numbers on the console.
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two option
1-java platform SE binary
2-java web starter lancher

now ,When i double click it is giving a error saying
could not find main class : filename .program will exit
Is it error in the Manifest class ? ?
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read my previous reply carefully.
Did you choose java.exe?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49432
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Tharakan wrote:I have two option
1-java platform SE binary
2-java web starter lancher

now ,When i double click it is giving a error saying
could not find main class : filename .program will exit
Is it error in the Manifest class ? ?
Don't know. What exactly have you got in the Manifest file? You need to use the exact format described here in the Java Tutorials, which Maneesh has already told you about. It might be easier to cheat and get an IDE to write the Manifest for you.
And there is another program you can use to launch the .jar namely javaw.

Try "javaw -jar MyJar.jar" in a batch file on Windows. See whether that works.
 
mahesh kale
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two free applications that let you create ".exe" from jar files. Also you can create installer as well.

These applications are :

Jsmooth
Lauch4J

You can google it for their webpages.
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Ok.

To change this, on windows, you can right click the jar file, select open with and choose java (instead of javaw)



Which file are you talking about???
jar.exe or myjar.jar
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Sheriff
Pie
Posts: 49432
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Tharakan wrote:
Please look at this FAQ.

I presume it meant the .jar file, not jar.exe.
 
Joseph Macer
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're asking a complex question that is not easily answered without actually being the developer who wants to "create exe file."
This is an EXCELLENT article that I consider required reading before you go any further:
http://www.excelsior-usa.com/articles/java-to-exe.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic