Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

run executable jar file

Posted on 2004-09-01
20
Medium Priority
?
529 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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 1000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

824 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