[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 534
  • Last Modified:

run executable jar file

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
thomas908
Asked:
thomas908
  • 7
  • 7
  • 2
  • +2
1 Solution
 
objectsCommented:
javaw.exe (or java.exe)
0
 
objectsCommented:
action should be configured as something like:

"C:\Program Files\Java\j2re1.4.2_05\bin\javaw.exe" -jar "%1" %*
0
 
armoghanCommented:
wHICH would be present in your Jre/bin or JDK
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
thomas908Author Commented:
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
 
lhankinsCommented:
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
 
thomas908Author Commented:
t has the manifest.mf file. But not running on doubleclick. Although works with the command

java -jar install.jar
0
 
objectsCommented:
> 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
 
objectsCommented:
you need to configure windows to handle jars, the jar itself is fine.
0
 
armoghanCommented:
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
 
JavatmCommented:
> 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
 
thomas908Author Commented:
i am getting the follwoing error

Could not find the main class. Program will exit
0
 
objectsCommented:
> 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
 
thomas908Author Commented:
I need to give this to the user to install the application. Does that she'll have to configure the same way
0
 
thomas908Author Commented:
>>Does that she'll have to configure the same way
Sorry typo

Does that mean she'll have to configure the same way
0
 
objectsCommented:
> Does that mean she'll have to configure the same way

The JRE installation should look after it for you.
0
 
thomas908Author Commented:
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
 
JavatmCommented:
Have you tried my suggestion yet?
0
 
objectsCommented:
after you have added you you can view/edit the actions associated with it.
0
 
lhankinsCommented:
>
> 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
 
thomas908Author Commented:
thanks everyone
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 7
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now