[Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Running jar file

I have a jar file called install.jar which each user needs to run on his system. Earlier I was distributing a batch file with it with the command
   java -jar install.jar
and the program would run. But now i want to allow the user to run the application by double clicking on the jar file (without using a batch file).

So i associated my jar file with javaw.exe

"C:\Program Files\Java\j2re1.4.2_05\bin\javaw.exe" -jar "%1" %*


as mentioned by objects in

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21116196.html

It works perfectly fine on my machine. But if i give the jar file to users to install the application then it doesn't work. Windows asks which program to use and after that doesn't do anything even if java.exe is selected.

How should i solve this?


0
thomas908
Asked:
thomas908
  • 12
  • 9
  • 6
  • +3
5 Solutions
 
CodingExpertsCommented:
Hi Thomas,
What i probably smell is that the binary of jre may be at different location for different users. You may check out on this.

Good Luck
CodingExperts
0
 
ramazanyichCommented:
Don't provide full path name to javaw, because user can have another version of java (JDK1.4.2_04 for example) on his PC. Usually JDK has a javaw and java put into system folder. So just use "javaw" -jar "%1" %* association
0
 
JavatmCommented:
The best of solution is to get an installer to install the jar file for you which includes the JVM w/ it. A good installer for that is InstallAnywhere from http://www.zerog.com it includes the JVM. So that you will not have any problems w/ it. There is a free download for IA but if you want to fully
customize it you will have to purchase it.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
thomas908Author Commented:
>>The best of solution is to get an installer to install the jar file for you which includes the JVM w/ it. A good installer for that is InstallAnywhere from http://www.zerog.com it includes the JVM. So that you will not have any problems w/ it. There is a free download for IA but if you want to fully
customize it you will have to purchase it.

i am using izpack installer and it made this jar file which user needs to install and i am looking fo a free solution
0
 
JavatmCommented:
As i said earlier its free usage unless you need to use the advance version.
0
 
girionisCommented:
thomas908 why don't you put a manifest in your jar file? Then users can run it by double clicking on it simply.
0
 
thomas908Author Commented:
there's a manifest.mf file  in it.
I can run it on my machine by double cllicking
0
 
thomas908Author Commented:
>>Don't provide full path name to javaw, because user can have another version of java (JDK1.4.2_04 for example) on his PC. Usually JDK has a javaw and java put into system folder. So just use "javaw" -jar "%1" %* association

Tried that doesn't help
0
 
objectsCommented:
the jre installation *should* setup that extension mapping, it certainly did when I installed.
What version is it not working with?
0
 
objectsCommented:
Easiest solution would be to go back to using the batch file.
0
 
thomas908Author Commented:
The jar file is created by Izpack installer. i don't think i can make any changes to any of its files
0
 
thomas908Author Commented:
>jre installation *should* setup that extension mapping, it certainly did when I installed.
What version is it not working with?
 I have version 1.4.1 and tried it on another machine with same version
0
 
girionisCommented:
>there's a manifest.mf file  in it.
>I can run it on my machine by double cllicking

Then you should be able to run it on any other machine that has java installed, at least on windows. Upon isntallation the jar files should be associated with java or javaw.
0
 
girionisCommented:
> The jar file is created by Izpack installer. i don't think i can make any changes to any of its files

What happens if you create the jar file yourself? Izpack might be putting files there that conflict with the java installation.
0
 
thomas908Author Commented:
>>Then you should be able to run it on any other machine that has java installed, at least on windows. Upon isntallation the jar files should be associated with java or javaw.

But they don't get associated
here is manifest.mf created by izpack

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_05-b04 (Sun Microsystems Inc.)
Built-By: IzPack
Main-Class: com.izforge.izpack.installer.Installer
Class-Path:

Name: com/izforge/izpack/installer/
Specification-Title: IzPack installer
Specification-Version: 0
Specification-Vendor: IzPack.
Implementation-Title: IzPack installer
Implementation-Version: 3.6
Implementation-Vendor: IzPack.


BEcause this is automatically created by izpack automatically , i won't be able to make any changes to it
0
 
objectsCommented:
its been included since at least 1.3 as far as i can remember.
Perhaps when you install you ask it not to, been a while since I've taken notice of an install :)

But your probably always going to come across environments where its not setup for double clicking, in which case the batch is required.

Why is the batch a problem ?
0
 
girionisCommented:
Can you look at izpack's documentation to see if you can find any help associating automatically jar files with java?
0
 
thomas908Author Commented:
>>Why is the batch a problem ?
User doesn't like it.
0
 
objectsCommented:
>>>Why is the batch a problem ?
>User doesn't like it.

Whats the difference?

And if they don't like it tell them to setup there computer to run jars correctly :)
0
 
objectsCommented:
How about giving them a shortcut instead of a batch.
In fact izpack may be able to do that for you.
0
 
thomas908Author Commented:
Yes it  does make shortcuts once the application is installed. But this jar is used to install the application
0
 
girionisCommented:
I really suggest you use installAnywhere. It is the best installer I have ever used.
0
 
thomas908Author Commented:
>> I really suggest you use installAnywhere. It is the best installer I have ever used.

Need a free option. There doesn't seem to be any free one here
http://zerog.com/zgfront_new.shtml
0
 
objectsCommented:
Why can't the user simply run it from the command line, what do they exect for free :)
0
 
objectsCommented:
is the installer a gui application?
0
 
thomas908Author Commented:
;)
0
 
thomas908Author Commented:
>>Is the installer a gui application?
Yes
0
 
objectsCommented:
0
 
thomas908Author Commented:
Thanks you all for helping
0
 
girionisCommented:
:)
0
 
objectsCommented:
hope we were some help :)

0
 
JavatmCommented:
=-) Always here to help . . .

http://freewebs.com/cube-j
Friend : Javatm
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 12
  • 9
  • 6
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now