Link to home
Start Free TrialLog in
Avatar of paramu83
paramu83

asked on

Setting Env Variables durin installation using iZPack

Suppose My application uses an external jar like say a comm.jar. In that case while installing using the iZPack how can i set the class path in the environment variables during installing the application using iZPack.I need to set the class path as my application uses external jar file.I need to do it during installation using iZPack itself?  
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Class-Path: other.jar
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>if you install then to the jre's ext directory

Personally i wouldn't disperse those files:

a. the user may not like your placing file in the ext directory - i wouldn't
b. it will break your application when a runtime upgrade occurs if you don't warn against this
Avatar of paramu83
paramu83

ASKER

Can you show exactly how to do that?
just give the commands
When you JAR your application, it will create a manifest file inside the JAR file. Edit it in some editor like Notepad and write:

>> Class-Path: other.jar

- for all other JARs that you use in your project.
You can try placing the JARs in one folder and run them with java -Djava.lib.ext=<folder Path> yourApplicationClass too.
>>java -Djava.lib.ext

I hope that isn't going to become a panacea now ;-)
Why?
Oh I just checked: https://www.experts-exchange.com/questions/21793084/How-to-Set-Java-Classpath-Size.html

- is that the one you are referring to ;-) ?
Yes ;-)
Oh, well.... :)
I tried out by keeping app jar in one folder and the other jar in some other.
It is not working when i give the absolute path.
In that case how should i set the path.
Also If I make a change in the Manifest file it is making a duplicate copy of that outside the META-INF folder and showing errors.
But in eclipse I can make the application refer to my Manifest file that I make rather than allowing it to make it self.
But it is not working with out eclipse.
If I jar the second jar file with in the main app's jar using eclipse how should I set the path in that case. I tried giving the path as ClassPath: App.jar
It is not working.
How should I give the class path in this particular case??
> It is not working when i give the absolute path.

its needs to be a relative path

And you need to specify the location of your manifest when u create the jar
You have to specify the manifest:

jar cvfm your.jar your.manifest X.class
> f I jar the second jar file with in the main app's jar using eclipse how should I set the path in that case. I

the jars need to be kept seperate, don't include the other jar inside your apps jar
>> If I jar the second jar file with in the main app's jar using eclipse how should I set the path in that case.

You can't do that. You *can* merger the jars if you want using Ant so you have just one jar
merger=merge
I would recommend keeping all JARs separate as they are so that they can also be used in other projects readily if required (like log4J, etc).
>>so that they can also be used in other projects readily

Merging a jar inside another doesn't exhaust it ;-)
> I would recommend keeping all JARs separate as they are so that they can also be used in other projects readily if required (like log4J, etc).

absolutely, the only place I've even seen mention of jarring everything in one blob was here. Funny the things people suggest to try and get a few points ;)
>>jarring everything in one blob

I do it frequently. It makes distribution and deployment (especially if you're not using an installer) a whole lot easier.

It would also make the current problem a lot easier to solve probably ;-)
May I know Why the 2 jars should be kept seperate please?
> May I know Why the 2 jars should be kept seperate please?

cause you don't want to be redeploying *everything* whenevr you just change one class.
You want to deploy just the jar that has been updated.
And if you have mutliple apps you also don't want to deploy duplicate set of jars with every app.
It also make break some licensing rules.

Not to mention that it is unnecessary, jars are there so you can break your classes up and not have to include them in one big blob.
Depends on the circumstances. It's often better in the long run with a small app to redistribute whole again - people tend to break things very easily. Having dependencies is a potential source of problems
>>Having dependencies is a potential source of problems

... and of course it's the cause of your current problems, although we can get these fixed probably ;-)
its not the cause of the current problems, my comments above will resolve the problems u are having :)

So what's the status of the problem now? Has it worked?
I have kept the jar files seperate. I could not edit the existing Manifest of the jar file. SO made a new manifest file and make the jar file use this manifest.

The problem is only giving the relative addressing. If they are in differnt drives how can i give the path?
>>If they are in differnt drives how can i give the path?

You can't internally. You'll have to specify the cp *ex*ternally
Well, maybe try keeping them in a relative directory or the same directory as the application and then just specify the name of the JAR.
If you're using an installer, you may as well use a batch file to start your app - it's more reliable than an executable jar anyway. You can put your jars wherever you want
why are they are different drives. Can't you injstall them all on the one drive?
> it's more reliable than an executable jar anyway

atually you'll find in real life that a batch is actually *less* reliable
>>atually you'll find in real life that a batch is actually *less* reliable

Well i don't know any other life and i've found them *more* reliable ;-)