Solved

Running jar file

Posted on 2004-09-01
32
3,012 Views
Last Modified: 2013-11-23
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
Comment
Question by:thomas908
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 9
  • 6
  • +3
32 Comments
 
LVL 6

Assisted Solution

by:CodingExperts
CodingExperts earned 20 total points
ID: 11960563
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
 
LVL 19

Assisted Solution

by:ramazanyich
ramazanyich earned 20 total points
ID: 11960574
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
 
LVL 15

Assisted Solution

by:Javatm
Javatm earned 20 total points
ID: 11960616
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 8

Author Comment

by:thomas908
ID: 11960634
>>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
 
LVL 15

Expert Comment

by:Javatm
ID: 11960817
As i said earlier its free usage unless you need to use the advance version.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11960917
thomas908 why don't you put a manifest in your jar file? Then users can run it by double clicking on it simply.
0
 
LVL 8

Author Comment

by:thomas908
ID: 11960958
there's a manifest.mf file  in it.
I can run it on my machine by double cllicking
0
 
LVL 8

Author Comment

by:thomas908
ID: 11960960
>>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
 
LVL 92

Expert Comment

by:objects
ID: 11960965
the jre installation *should* setup that extension mapping, it certainly did when I installed.
What version is it not working with?
0
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 11960970
Easiest solution would be to go back to using the batch file.
0
 
LVL 8

Author Comment

by:thomas908
ID: 11960973
The jar file is created by Izpack installer. i don't think i can make any changes to any of its files
0
 
LVL 8

Author Comment

by:thomas908
ID: 11960985
>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
 
LVL 35

Assisted Solution

by:girionis
girionis earned 40 total points
ID: 11960989
>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
 
LVL 35

Expert Comment

by:girionis
ID: 11960999
> 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
 
LVL 8

Author Comment

by:thomas908
ID: 11961007
>>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
 
LVL 92

Expert Comment

by:objects
ID: 11961008
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
 
LVL 35

Expert Comment

by:girionis
ID: 11961016
Can you look at izpack's documentation to see if you can find any help associating automatically jar files with java?
0
 
LVL 8

Author Comment

by:thomas908
ID: 11961019
>>Why is the batch a problem ?
User doesn't like it.
0
 
LVL 92

Expert Comment

by:objects
ID: 11961033
>>>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
 
LVL 92

Expert Comment

by:objects
ID: 11961051
How about giving them a shortcut instead of a batch.
In fact izpack may be able to do that for you.
0
 
LVL 8

Author Comment

by:thomas908
ID: 11961128
Yes it  does make shortcuts once the application is installed. But this jar is used to install the application
0
 
LVL 35

Expert Comment

by:girionis
ID: 11961150
I really suggest you use installAnywhere. It is the best installer I have ever used.
0
 
LVL 8

Author Comment

by:thomas908
ID: 11961170
>> 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
 
LVL 92

Expert Comment

by:objects
ID: 11961177
Why can't the user simply run it from the command line, what do they exect for free :)
0
 
LVL 92

Expert Comment

by:objects
ID: 11961183
is the installer a gui application?
0
 
LVL 8

Author Comment

by:thomas908
ID: 11961187
;)
0
 
LVL 8

Author Comment

by:thomas908
ID: 11961191
>>Is the installer a gui application?
Yes
0
 
LVL 92

Expert Comment

by:objects
ID: 11961309
0
 
LVL 8

Author Comment

by:thomas908
ID: 11961447
Thanks you all for helping
0
 
LVL 35

Expert Comment

by:girionis
ID: 11961467
:)
0
 
LVL 92

Expert Comment

by:objects
ID: 11961473
hope we were some help :)

0
 
LVL 15

Expert Comment

by:Javatm
ID: 11968342
=-) Always here to help . . .

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

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

728 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