Solved

Running Java aplication in Windows

Posted on 2002-04-13
22
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

726 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