2007 How to: COMPILE \ RUN java programs (code) in Windows (XP...) as a standalone app? BEST WAY

2007 How to: COMPILE \ RUN java programs (code) in Windows (XP...) as a standalone app? BEST WAY

I have found numerous postings for this question but most are outdated, poorly answered or incomplete. So maybe this could be definitive...

COMPILING \ RUNNING java programs (code) in Windows (XP...)

I am unclear on how to "BEST" take my java program (.java) or create a (.class or .jar) and then send this to my friends and family who have Windows XP and have them be able to execute the program as a standalone app.

Many posts say I should just be able to double-click the .jar or .class file but this doesn't seem to work for many people. Some posts just offer links to apps that can create an .exe file (fine with me but they seem testy and flaky unless someone uses "a really good one.").

Some posts even want me to open a dos prompt and type java -cp .. whatever, no way!

So what is the BEST way to make my code portable as an executable (i.e. "Hey Jim! Just download this game I wrote in java into any folder and just double-click, it is so cool!"

Any help clearing up this "mysterious, why?" issue would be GREATLY appreciated!


Karl66
Karl66Asked:
Who is Participating?
 
CEHJCommented:
You can use Java Web Start. That will install a JRE if it's missing. jars are only going to work under special circumstances
0
 
Karl66Author Commented:
Java Web Start software provides a flexible and robust deployment solution for Java technology-based applications based on the Java Community Process program (JCP).?

CEHJ are you saying that "Java Web Start" will compile my .class file to an .exe? If not how exactly will this help me make my apps standalone and portable and is this the BEST way to do this?

Thanks in adavance!
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
CEHJCommented:
No. JWS works by serving your app from a web server, packaged and deployed in such a way that the correct runtime is installed. exe files are platform-specific, which somewhat defeats the object of Java
0
 
Karl66Author Commented:
OK. Anyone have thoughts if I wanted to make the app Windows platform specific? A decent compiler? Jet exe4j or something else. It is possible I am being dense here but it seems that my whizzy java gui apps I have written should be able to launch for people as standalone apps on my windows box.
0
 
CEHJCommented:
Dependency free Java (i.e. a runtime) is really a kind of contradiction in terms. If that's what you want, you're really working in the wrong language if you need to produce executables. Java is an interpreted lanaguage and therefore needs an interpreter. Using JWS will ensure that dependencies are resolved in as painless a way as possible
0
 
Mayank SAssociate Director - Product EngineeringCommented:
You can always look at JARing your classes together to ensure smooth portability across platforms:

http://java.sun.com/docs/books/tutorial/deployment/jar/

You also get the advantages of signing, security, manifest, etc
0
 
Karl66Author Commented:
CEHJ - thanks.

I am moving from the C world and like java. I have written some code I like and want to make it available. I ask the following then to make sure I am clear:

You do not like the compilers I hear so much about such as jet?
There is no way through Netbeans 5.5 I can create a file I can email and have person2 execute?
Using a JWS solution is the way most people make their "stuff" available?
Am I on-track?

Thanks again.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> There is no way through Netbeans 5.5 I can create a file I can email and have person2 execute?

You can create an executable JAR file and send it, assuming the other person has the same version of Java available to run it
0
 
Karl66Author Commented:
mayankeagle -

Are you saying they can double-click - would they need the same runtime or JDE as in exactly the same version? What is really really really the best way to send someone a java app and say run this have a nice day. I cannot believe it is such a rabbit hole but I guess it is.

Thanks
0
 
Mayank SAssociate Director - Product EngineeringCommented:
They can double click on it and run if it they have a JRE (preferably same version or higher than yours) and if their default opener for .jar files is java.exe or javaw.exe
0
 
CEHJCommented:
>>You do not like the compilers I hear so much about such as jet?

Not really, as there's not much point in writing in an interpreted language if one's intention is to produce a native executable. All things like Jet do is to bundle an interpreter with your code and wrap it in an exe.

If you're really keen on Java -> native code, you'd be better to use gcj with Cygwin (assuming Windows) then you'll get genuine native code
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> code portable as an executable

If it is executable (as an EXE) it might not be portable to all platforms - what exactly do you want? A standard thing to port to all platforms, or multiple platform-specific native executables?
0
 
Karl66Author Commented:
Good question. Here is what happened...

Work wanted a GUI front end that would query an excel (ODBC) spreadsheet and give results based on the GUI inputs. I ws taking java in college - wrote it. It works. I like it. I googled how do I make my java program portable to my windows clients. I got silence.... as if I was asking how to make gold from water. So all I really need now is a good way to make a windows exe - I would love to try CEHJ's web delivery thought (if a simple implimentation) or his exe creator gcj (for which I am still searchng a working download link [CEHJ have one?]) but for now I want to zip up a sheet and an exe and say "have a nice day"

Thanks guys
Karl
0
 
Mayank SConnect With a Mentor Associate Director - Product EngineeringCommented:
0
 
CEHJCommented:
If you want gcj, it's part of gcc, both of which will require Cygwin (or MinGW) to be installed first if you're on Windows:

http://sourceware.org/cygwin/

http://www.mingw.org/
0
 
Karl66Author Commented:
RESOLVED:

I had all clients simply update to the the latest JRE, I used exe4j (free trial) to make a Windows exe. Zipped everything up (the database and the exe and the JRE 6 download) and it works. I will accept multiple answers as CEHJ is right but I needed mayankeagles blance of OK if you must...

thanks all
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.