Solved

run executable jar file

Posted on 2004-09-01
20
515 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.

914 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

22 Experts available now in Live!

Get 1:1 Help Now