classpath in jar files

Frnz

i have a jar file of my app with me and i used to execute this

as java - jar myapp.jar.

I have a manifest file inside the jar.

My requirement is that one of the file inmyapp.jar requires a class

which is available in say another jar(another.jar).

This requirement can be fulfilled by adding that jars' name (ie

another.jar) in the manifest file inside myapp.jar.

But the issue is that theanother.jar shud be taken from the machine specific directory which is not fixed.

ie we cannot sayd:\another.jar.

Instead it shud be say$MY_PATH/another.jar where $MY_PATH is an environment variable in that machine.

Also i know that in the manifest we cannot gived:\another.jar as

the URLs in the Class-Path header (in the manifest file) are given

relative to the URL of the JAR file of the application.

But i need to set the classpath at any cost.

i tried using say

java-cp $MY_PATH/another.jar -jar myapp.jar

But itz saying that class not found.

Any idea how i can proceed...

Thanks in advance..

[1167 byte] By [TigerXXa] at [2007-11-27 8:30:27]
# 1

hey i think there is a workaround

we can use say

java -cp $MY_PATH/another.jar;myapp.jar <Main Class in the manifest>

rather than -jar option.

I think the if we use -jar then all the classpath settings will be overridden and java thinks that the JAR file is the source of all the classes(if we have a classpath header in the manifest)

anyway

java -cp $MY_PATH/another.jar;myapp.jar <Main Class in the manifest>

worked for me...

:-)

cheers

TigerXX

TigerXXa at 2007-7-12 20:21:03 > top of Java-index,Desktop,Deploying...
# 2

put ur external jar file in any relative path from appjar.jar

in manifest add external jar's path

e.g

Manifest-Version: 1.0

Class-Path: relative_path_to_external_file/externaljar1.jar relative_path_to_external_file/externaljar2.jar

consider following points :

1.one line takes 72 chars

2.space between 2 classpath entries

3. space at start and end of line

z_idanea at 2007-7-12 20:21:04 > top of Java-index,Desktop,Deploying...