How to run a java class file direct from Windows Explorer?

B

Bengan

Hi,

I want to run my java files just by double clicking on them in Windows Explorer
or through a shortcut. How do you do that? I want it to be easy for my friends
to run them. What more do a person need to run the java application? Is it
enough with the java virtual machine or most you have the complete Java(TM)
2 Runtime Environment/Java(TM) 2 SDK?

Thanks in advance
/Bengan
 
K

Kyle Walz

I'm guessing by saying Windows Explorer, you mean, for example,
opening My Documents and double clicking something and it runs. Make
a self executable jar file.

Jar your classes and include a manifest.mf file. In the manifest file
you need to state the main class and (for packages) the class path:

Main-Class: package/Application
Class-Path: package

Put the manifest file in a folder named META-INF and your package
folder in the same folder. I place these in a folder I made just for
jarring (work/META-INF and work/package). Navigate to the folder with
the meta and package folder (work in my example). Then at the command
line for this folder type:

jar cvmf META-INF/manifest.mf jarFile.jar .

Or, use JavaJar from Pivotonic (http://www.pivitonic.com). :)

Then, the person needs the JVM to run the jar. Hope this helps.

Kyle
 
B

Bengan

Thanks for your answer. What JVM does the user need to have to run my applications.
I'm not quite sure what on java.sun.com homepage different download packages
is enough to just run a java application. There is one called Java VM and
it's about 8mb. Is it enough with this? Under the link J2SE 1.4.2 SDK there
is a column named JRE, is it perhaps this JRE you need?

Then i wonder if you have any suggestion of how to distribuate the jvm to
the user with my application in a simple way.

/Bengan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top