Solved

run executable jar file

Posted on 2004-09-01
20
514 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now