This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes .jar or .exe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark ".jar or .exe" Watch ".jar or .exe" New topic

.jar or .exe

Forrest Xu
Ranch Hand

Joined: Nov 16, 2002
Posts: 92
an executable file is .jar for Java. but we normally use .exe file.
How can I do that?
one option is that c++ code includes "SHELLAPI.H".
any other option?
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
If you compile your java code into an .exe then it is NOT platform independant.
A better solution is to have a .bat or .sh file to invoke your app. Then only THAT portion is platform dependant.
Of course you can just use the .jar file anyway.
What do you have against it?
[ December 04, 2002: Message edited by: Cindy Glass ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
Forrest Xu
Ranch Hand

Joined: Nov 16, 2002
Posts: 92
Thank you for you replay!
you provided another option for it.
The reason I don't like it is that in window platform the customer always uses mouse to click the executable file to launch the application.
jar file needs to enter something by hands.
I saw someone's java code, their executable file is exe file.
how can we do that if we do not use .bat or .sh?
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
You can also make jar-files "double-clickable" by providing a manifest. See - especially "Applications bundled as JAR files"

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

You could also make an EXE file that invokes the VM and calls your main method. That of course is platform dependent, but it is another option.
Here is a link on how to invoke the Java Virtual Machine using the DLL that Sun provides with the JDK/JRE.

GenRocket - Experts at Building Test Data
Forrest Xu
Ranch Hand

Joined: Nov 16, 2002
Posts: 92
Here is a link on how to invoke the Java Virtual Machine using the DLL that Sun provides with the JDK/JRE.
I think Gregg Bolinger provides the best option.
do you agree with that?
Tom Purl
Ranch Hand

Joined: May 24, 2002
Posts: 104
I used a couple of java apps and the vast majority of them *don't* use .exe's. Typically, they offer two executable files; a .bat file (for the Windows platform) and a .sh file (for the Linux/UNIX platform). Both files can be executed by double-clicking on them.
In the past, my only concern with providing a .bat file instead of a .exe file was that it would confuse the end user. However, after using a few programs that use .bat files instead of .exe files, I found that the average end user sees no difference.
So basically, unless you are building a program that is strictly Windows-dependent, build a .bat executable and a .sh executable. This allows more people to use your code. Of course, it all depends on your requirements. Plus, even if your program is Windows-specific, it's gotta be easier to create a .bat file rather than an .exe file.

Tom Purl<br />SCJP 1.4
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
I like the executable JAR file.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: .jar or .exe
It's not a secret anymore!