a java classpath question

Z

zyng

Hi:

My Java program is started by using somebody's shell script. Inside his script:

java -classpath his_lib/'*' Main

However, I also wish to set Java's classpath for my code to work and I am not allowed to change his script.(He: actually is a company. My program is running inside this company's main frame).

So when JVM starts, the true classpath is my_lib/'*';his_lib/'*'. Is that possible to do?

Thank you.
 
A

Arne Vajhøj

My Java program is started by using somebody's shell script. Inside
his script:

java -classpath his_lib/'*' Main

However, I also wish to set Java's classpath for my code to work and
I am not allowed to change his script.(He: actually is a company. My
program is running inside this company's main frame).

So when JVM starts, the true classpath is my_lib/'*';his_lib/'*'. Is
that possible to do?

No.

For that to be possible his shell script should have used
a variable that you could have set.

I would copy his shell script and modify it.

Arne
 
Z

zyng

OK. Thanks. But I can not make it work. In the script:

his_lib=/a/b
my_lib=/c/d

java -classpath $his_lib/'*' Main //old script and it works

java -classpath $his_lib/'*';$my_lib/'*' Main //not working, saying /c/d/*: No such file or directory

Confused.
 
Z

zyng

OK. Thanks. But I can not make it work. In the script:



his_lib=/a/b

my_lib=/c/d



java -classpath $his_lib/'*' Main //old script and it works



java -classpath $his_lib/'*';$my_lib/'*' Main //not working, saying /c/d/*: No such file or directory



Confused.

Wow, this is working:
java -classpath $his_lib/'*':$my_lib/'*' Main //using ":" not ";" to separate

(Obviously, I am on Linux.)

But, this document is using ";", not ":"
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html
 
A

Arne Vajhøj

OK. Thanks. But I can not make it work. In the script:

his_lib=/a/b
my_lib=/c/d

java -classpath $his_lib/'*' Main //old script and it works

java -classpath $his_lib/'*';$my_lib/'*' Main //not working, saying /c/d/*: No such file or directory

Confused.

On *nix I think classpath elements is separated by : not ;.

Arne
 
R

Roedy Green

However, I also wish to set Java's classpath for
my code to work and I am not allowed to change his script.
(He: actually is a company. My program is running inside this company's main frame).

Things to try:

1. classpath set in jar manifest.

2. custom classloader

3. setting system property (I have not tried this).
 
R

Roedy Green

My Java program is started by using somebody's shell script. Inside his script:

java -classpath his_lib/'*' Main

you could write a dummy java program that execs your real program.
 
J

John L.

Hi: My Java program is started by using somebody's shell script. Inside his script: java -classpath his_lib/'*' Main However, I also wish to set Java's classpath for my code to work and I am not allowed to change his script..(He: actually is a company. My program is running inside this company's main frame). So when JVM starts, the true classpath is my_lib/'*';his_lib/'*'.. Is that possible to do? Thank you.

At the risk of stating the obvious, perhaps set the %CLASSPATH% environmentvariable (or its Unix equivalent) prior to invoking your colleague's script.
 
A

Arne Vajhøj

At the risk of stating the obvious, perhaps set the %CLASSPATH%
environment variable (or its Unix equivalent) prior to invoking your
colleague's script.

The -cp argument override CLASSPATH env - it does not supplement it.

Arne
 
A

Arne Vajhøj

you could write a dummy java program that execs your real program.

OP could do that.

But if is not an option to change the shell script, then it does
not help.

If it is an option to change the shell script, then the dummy
program is not needed.

Arne
 
A

Arne Vajhøj

At the brisk of stating another obvious point, whats wrong with this
summary of the situation?

1) the owner of the computer wants your program to be run on it.
2) an existing script must be changed for your program to run
3) the computer's sysadmins won't let anybody else change scripts
on production systems. (a fairly common situation).

However this leaves the obvious outstanding question: why won't the
sysadmins, i.e. 'the company', make the changes needed for your program
to run?

Do you read Dilbert?

:)

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top