Welcome to Dream.In.Code
Getting Java Help is Easy!

Join 86,390 Java Programmers. There are 1,373 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Java Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Why my jar file cannot double click ?

 
Reply to this topicStart new topic

Why my jar file cannot double click ?

fsloke
post 7 May, 2008 - 08:21 PM
Post #1


D.I.C Head

**
Joined: 19 Dec, 2007
Posts: 101



Why my jar file cannot double click?

I already installed the JDK, how can I make a jar file can double click without typing execute in command prompt?

[java -jar file.jar]


Thank
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


no2pencil
post 7 May, 2008 - 08:30 PM
Post #2


DIC K-mart

Group Icon
Joined: 10 May, 2007
Posts: 3,324

a Jar file is not a binary executable. The easiest way to make it double clickable, is to make a script file (.sh for linux or .bat for Windows) that will run the java interpreter, with the jar file, like you have posted. So you double click the script, & the script launches Java.
User is online!Profile CardPM
Go to the top of the page
+Quote Post

pbl
post 7 May, 2008 - 08:33 PM
Post #3


D.I.C Addict

Group Icon
Joined: 6 Mar, 2008
Posts: 849

QUOTE(fsloke @ 7 May, 2008 - 08:21 PM) *

Why my jar file cannot double click?

I already installed the JDK, how can I make a jar file can double click without typing execute in command prompt?

[java -jar file.jar]


Thank


Does your .jar contain a manifest file ?
The manifest file says which class main() method in the package should be executed
Here is an example of a manifest file:

File name: manifestEuroStyle.mf
CODE

Main-Class: ca/pblinc/eurostyle/EuroStyle


whicch means when the .jar file is executed execute ca.pblinc.eurostyle.EuroStyle.main()

and the way to create the .jar file

CODE

jar -cmf0 manifestEuroStyle.mf EuroStyle.jar ca org jxl


the "m" means that there is a manifest file called manifestEuroStyle.mf
then the EuroStyle.jar file should contains the directory ca, org, jxl
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

born2c0de
post 8 May, 2008 - 06:42 AM
Post #4


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,298

QUOTE
I already installed the JDK, how can I make a jar file can double click without typing execute in command prompt?

Yes, there is. smile.gif

Right Click any JAR file and select Open With->Choose Program.
Once the new Dialog Box opens, choose Java™ 2 Platform Standard Edition binary or an appropriate version and click the Always use the selected program to open this kind of file Checkbox and click OK.

JAR files can then be opened with a double-click.

Note : The same thing can be done from the File Types Tab in the Folder Options Dialog Box available by clicking Tools->Folder Options in Windows Explorer.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/17/08 04:57AM

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month