thomas908
asked on
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.
I am using windows.
javaw.exe (or java.exe)
action should be configured as something like:
"C:\Program Files\Java\j2re1.4.2_05\bi n\javaw.ex e" -jar "%1" %*
"C:\Program Files\Java\j2re1.4.2_05\bi
wHICH would be present in your Jre/bin or JDK
ASKER
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.
I can run it using
java -jar install.jar
does that mean it is also executable and i can run it using doubleclick.
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)
Main-Class: com.acme.MyMainClass
(replace my com.acme.MyMainClass with the qualified name of your class which contains the appropriate main)
ASKER
t has the manifest.mf file. But not running on doubleclick. Although works with the command
java -jar install.jar
java -jar install.jar
> 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.
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.
you need to configure windows to handle jars, the jar itself is fine.
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
and click Ok
All the jar files will be associated with Javaw
> 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
> 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
ASKER
i am getting the follwoing error
Could not find the main class. Program will exit
Could not find the main class. Program will exit
> 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
> and click Ok
that won't work, you need to congigure it as i specified earlier
ASKER
I need to give this to the user to install the application. Does that she'll have to configure the same way
ASKER
>>Does that she'll have to configure the same way
Sorry typo
Does that mean she'll have to configure the same way
Sorry typo
Does that mean she'll have to configure the same way
> Does that mean she'll have to configure the same way
The JRE installation should look after it for you.
The JRE installation should look after it for you.
ASKER
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\bi n\javaw.ex e" -jar "%1" %*
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\bi
Have you tried my suggestion yet?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>
> 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.
> 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.
ASKER
thanks everyone