It's not a secret anymore!
The moose likes Java in General and the fly likes Is there any way?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is there any way??" Watch "Is there any way??" New topic

Is there any way??

Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

I have developed a Java Program using Swing and other packages.
And I want to give this program to my friend to test it, my friend has JRE installed in his machine.
So how to put my program in a jar format to use it?
(I mean, is there some way to use jar format, so when my friend "double-clicked" in this jar my application will start?)
Waiting for your answers ranchers.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24193

There are two parts to the answer. One part is that the JAR file's WEB-INF/MANIFEST.MF file has to have a "Main-Class" entry that points to the main class of the application.
The other part is that your friend's computer has to be properly configured to handle clickable JAR files -- I think Sun's standard installer sets this up automatically, so he should be all set.
Here are some more details.

[Jess in Action][AskingGoodQuestions]
Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

Thank you very much DR.Friedman-Hill, I found a tutorial from
but this tutorial said :
"Assuming your text file was in a file called mainClass, you could merge it into a JAR file's manifest with a command such as this:
jar cmf mainClass app.jar HelloWorld.class "
I tried this command, but the following exception is thrown:
FileNotFoundException: mainClass (The system can't find the file specified)
So what is the problem??
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Uh... the system can't find the file "mainClass"? Is there a file called "mainClass" in the current directory?

"I'm not back." - Bill Harding, Twister
Robbie Harjes

Joined: Nov 09, 2003
Posts: 22
Or.. Do what I've done... Send the class (or java file and have him compile it), and a small batch file that contains this:

Although I haven't tried it yet.. Put that all in a .exe file.. Iunno, might work.
I agree. Here's the link:
subject: Is there any way??
It's not a secret anymore!