Solved

run executable jar file

Posted on 2004-09-01
20
523 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
throw exception 21 79
pagenation logic how it is working in my code 1 82
ejb on wildfly 5 64
program arguments vs VM arguments 4 58
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…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

751 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