Solved

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

Posted on 2007-03-20
18
401 Views
Last Modified: 2010-03-31
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
0
Comment
Question by:Karl66
  • 7
  • 6
  • 5
18 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 18759504
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 total points
ID: 18759508
0
 

Author Comment

by:Karl66
ID: 18759567
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 86

Expert Comment

by:CEHJ
ID: 18759839
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
 

Author Comment

by:Karl66
ID: 18760023
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 18760071
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 18760109
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
 

Author Comment

by:Karl66
ID: 18760793
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 18760839
>> 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
 

Author Comment

by:Karl66
ID: 18761121
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 18761531
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 18762459
>>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
 
LVL 30

Expert Comment

by:Mayank S
ID: 18768881
>> 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
 

Author Comment

by:Karl66
ID: 18768923
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
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 125 total points
ID: 18768938
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18769711
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
 

Author Comment

by:Karl66
ID: 18836188
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 18836217
:-)
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JDeveloper 12c for 32 bit 4 84
fibonacci ten numbers 4 38
tomcat not starting 6 45
Running JavaFX on JDeveloper 12C 1 32
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues undeā€¦
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question