Solved

Running Java aplication in Windows

Posted on 2002-04-13
22
220 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 92

Expert Comment

by:objects
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
You've all been greeeeeeeeat.
aftrbrnr.
0
 

Author Comment

by:afterburner
Comment Utility
Much appreciated.
0
 
LVL 5

Expert Comment

by:nebeker
Comment Utility
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
Comment Utility
Right.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now