aspose file tools*
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
Author

.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?
thanks,
Cindy Glass
"The Hood"
Sheriff

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?
thanks.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
You can also make jar-files "double-clickable" by providing a manifest. See http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html - 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: 15299
    
    6

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?
Thank ALL OF YOU!
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
Sheriff

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


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: .jar or .exe