Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there any way??

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Survive.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much DR.Friedman-Hill, I found a tutorial from java.sun.com
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
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Uh... the system can't find the file "mainClass"? Is there a file called "mainClass" in the current directory?
 
Robbie Harjes
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic