Solved

Running Java aplication in Windows

Posted on 2002-04-13
22
249 Views
Last Modified: 2010-03-31
Once you've finished a Java application, what does another user need to run it under Windows? How do you get the app installed and run-clickable? I know this must sound like a daft question, but I just done get it!

Any one got the answer, please?
0
Comment
Question by:afterburner
  • 9
  • 7
  • 3
  • +2
22 Comments
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 6938950
A simple way is that you may try to package your Java application into exe using Java2exe.

Java2exe:
http://www.duckware.com/java2exe/index.html

I have not tried it out. Please have a try on it, and tell us if this works.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6938965
Or just create a Windows shortcut where the command is something like:
C:\jdk1.4\bin\java.exe c:\Main
You may need to put in the classpath as a parameter before the main class
0
 
LVL 5

Expert Comment

by:nebeker
ID: 6939459
If you use one of the commerical Installers available, they will do this automatically for you (i.e. create a custom launcher program)...

I've used InstallAnywhere by ZeroG software (http://www.zerog.com) and have been quite pleased with the results.  If you have a very simple application, their InstallAnywhere NOW! product is absolutely free, and will handle all of the basic installer needs.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 92

Expert Comment

by:objects
ID: 6940763
Converting to an exe may suit your needs but it does have limitations.

Another possibility is to create an executable jar. When the jre is installed it generally sets up a file association under Windoze for starting an executable jar.
An executable jar is simply a jar file, with the name of the main class specified in the Manifest using the Main-Class attribute. It can then be started without knowledge of the main class name.


0
 

Author Comment

by:afterburner
ID: 6953390
CEHJ

I dont get the C:\Main thing.

Suppose my class is called X, on C:, then would I need ..

C:\DirContainingJava.exe\java.exe c:\X.Main()

or what?

Thanks.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6953425
Sorry about that. A bit of a slip on my part. Give me the following and I'll supply the text for the shortcut:

1. Path to java.exe
2. Path to your class
3. Name of your class

I can assure you shortcuts are perfectly workable. You can even add you own custom Java icon!

0
 

Author Comment

by:afterburner
ID: 6953462
CEHJ

I have several java.exes on the machine it appears. However, I reckon I could handle that; so say the path is C:\MyJavaExeDir, and the class is called myClass and is in C:\MyClassDir.
0
 

Author Comment

by:afterburner
ID: 6953466
CEHJ

I have several java.exes on the machine it appears. However, I reckon I could handle that; so say the path is C:\MyJavaExeDir, and the class is called myClass and is in C:\MyClassDir.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6953497
Well there's no mystery here, but test it at the command line first - if it doesn't work from there, it sure as hell won't inside the shortcut!

C:\MyJavaExeDir\java.exe -classpath %CLASSPATH%;C:\MyClassDir myClass

Left-click the desktop
New | Shortcut
Paste in the command line

You might find you can shorten -classpath to -cp. I do!
0
 
LVL 92

Expert Comment

by:objects
ID: 6955144
If you create an executable jar, then you can simple d-click on that file, you do not need to create a shortcut.
0
 

Author Comment

by:afterburner
ID: 6959591
I am now confused as to what exactly the difference is between java.exe and javaw.exe. They both seem to do the same thing.

How do you ever know that another computer can run your java app (not aplet) anyway? What does another PC need on it to run my app?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6959615
objects is almost certainly right, but I've never created an executable jar file.

The difference between javaw.exe and java.exe is that the former does not have a console window.

Any machine that has the runtime environment will be able to run it. Look for the executable called 'java' (java.exe on Windows, java on Unix)
0
 

Author Comment

by:afterburner
ID: 6959771
Before I close this question, can I ask then if someone does not have java on their machine, do you just copy the java executable over to them? Do they need any other supporting files?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6959781
No, it's not quite as simple as copying java.exe over. You must *install* the JRE (Java Runtime Environment)
0
 
LVL 5

Expert Comment

by:nebeker
ID: 6959783
You would need the entire runtime (JRE) environment.  Just the java.exe won't work, because you also need the supporting native libraries (dll's) and runtime jar files.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6959791
No, it's not quite as simple as copying java.exe over. You must *install* the JRE (Java Runtime Environment)
0
 

Author Comment

by:afterburner
ID: 6960378
And am I permitted to supply a third party with all the files etc needed for that, and where does it all come from?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 160 total points
ID: 6960401
Yes, you are, and it comes from Sun at http://java.sun.com. This site's getting messy to navigate, but look for the JRE
0
 

Author Comment

by:afterburner
ID: 6960521
You've all been greeeeeeeeat.
aftrbrnr.
0
 

Author Comment

by:afterburner
ID: 6960529
Much appreciated.
0
 
LVL 5

Expert Comment

by:nebeker
ID: 6960543
The JRE is freely distributable with your Java application.   For applets, the Java plugin is freely available...

The JDK/SDK is not freely distributable....
0
 

Author Comment

by:afterburner
ID: 6960639
Right.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 52
servlet doXXX methods 3 62
mysql jsp example issue 32 48
Eclipse Help Java EE 5,6,7 Documentation, why not Java EE 8 8 30
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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

856 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