Solved

run executable jar file

Posted on 2004-09-01
20
522 Views
Last Modified: 2010-03-31
How can i run a executable jar file. If I double click it it asks me to select a program to open this with. Which program should i choose.
I am using windows.
0
Comment
Question by:thomas908
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
  • 2
  • +2
20 Comments
 
LVL 92

Expert Comment

by:objects
ID: 11959836
javaw.exe (or java.exe)
0
 
LVL 92

Expert Comment

by:objects
ID: 11959842
action should be configured as something like:

"C:\Program Files\Java\j2re1.4.2_05\bin\javaw.exe" -jar "%1" %*
0
 
LVL 18

Expert Comment

by:armoghan
ID: 11959847
wHICH would be present in your Jre/bin or JDK
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Author Comment

by:thomas908
ID: 11959876
Does not show anything. a prompt window opens and disappears.
I can run it using
 java -jar install.jar

 does that mean it is also executable and i can run it using doubleclick.
0
 
LVL 7

Expert Comment

by:lhankins
ID: 11959893
The Jar file also has to contain a special "Main-Class" entry in its manifest to be used this way.   In other words, the manifest.mf file has to contain something like :

    Main-Class: com.acme.MyMainClass

(replace my com.acme.MyMainClass with the qualified name of your class which contains the appropriate main)
0
 
LVL 8

Author Comment

by:thomas908
ID: 11959928
t has the manifest.mf file. But not running on doubleclick. Although works with the command

java -jar install.jar
0
 
LVL 92

Expert Comment

by:objects
ID: 11959932
> does that mean it is also executable and i can run it using doubleclick.

you need to associate a jar file with an appropriate action like I posted above.

goto folder options>file types to add a new action.
0
 
LVL 92

Expert Comment

by:objects
ID: 11959957
you need to configure windows to handle jars, the jar itself is fine.
0
 
LVL 18

Expert Comment

by:armoghan
ID: 11960016
Right Click on the Jar file -> Click change-> Browser to the javaw file -> check the always use checkbox
and click Ok
All the jar files will be associated with Javaw
0
 
LVL 15

Expert Comment

by:Javatm
ID: 11960034
> I can run it using java -jar install.jar
> does that mean it is also executable and i can run it using doubleclick.

If its working through java -jar install.jar then try double click it. if it does not show up then :
Reinstall the installer for JRE or reinstall your JDK.

It happend to me before and I've done what I'm suggesting and it did work.

Hope that helps . . .
Javatm
0
 
LVL 8

Author Comment

by:thomas908
ID: 11960048
i am getting the follwoing error

Could not find the main class. Program will exit
0
 
LVL 92

Expert Comment

by:objects
ID: 11960051
> Right Click on the Jar file -> Click change-> Browser to the javaw file -> check the always use checkbox
> and click Ok

that won't work, you need to congigure it as i specified earlier

0
 
LVL 8

Author Comment

by:thomas908
ID: 11960078
I need to give this to the user to install the application. Does that she'll have to configure the same way
0
 
LVL 8

Author Comment

by:thomas908
ID: 11960082
>>Does that she'll have to configure the same way
Sorry typo

Does that mean she'll have to configure the same way
0
 
LVL 92

Expert Comment

by:objects
ID: 11960089
> Does that mean she'll have to configure the same way

The JRE installation should look after it for you.
0
 
LVL 8

Author Comment

by:thomas908
ID: 11960310
I have windows 2000 pro.
Selected folder options, file types and clicked New. It is asking me file extension and associated file type. But htere is no place to add
C:\Program Files\Java\j2re1.4.2_05\bin\javaw.exe" -jar "%1" %*
0
 
LVL 15

Expert Comment

by:Javatm
ID: 11960312
Have you tried my suggestion yet?
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 11960319
after you have added you you can view/edit the actions associated with it.
0
 
LVL 7

Expert Comment

by:lhankins
ID: 11960321
>
> i am getting the follwoing error
>
> Could not find the main class. Program will exit
>

Did you produce the jar in question...?   If so, make sure to add the Main-Class attribute to the manifest (as I mentioned in my earlier post).   BTW - a single Jar can have more than one class with a main in it (you might have test mains in several classes).   This manifest attribute determines which class gets executed when you treat it as an executeable jar.


0
 
LVL 8

Author Comment

by:thomas908
ID: 11960325
thanks everyone
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Way to decrease size of apk file 9 107
eclipse apache tomcat admin console 52 150
What's wrong with this code? 4 34
How to determine if a string is a valid SHA value 7 43
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

756 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