Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > a java classpath question

Reply
Thread Tools

a java classpath question

 
 
zyng
Guest
Posts: n/a
 
      12-28-2012
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.
 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-28-2012
On 12/28/2012 12:07 PM, zyng wrote:
> 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
 
Reply With Quote
 
 
 
 
zyng
Guest
Posts: n/a
 
      12-28-2012
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.
 
Reply With Quote
 
zyng
Guest
Posts: n/a
 
      12-28-2012
On Friday, December 28, 2012 1:44:13 PM UTC-5, zyng wrote:
> 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...classpath.html
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-28-2012
On 12/28/2012 1:44 PM, zyng wrote:
> 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


 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-28-2012
On 12/28/2012 1:48 PM, zyng wrote:
> On Friday, December 28, 2012 1:44:13 PM UTC-5, zyng wrote:
>> 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...classpath.html

^^^^^^^

It says Windows.

You want:

http://docs.oracle.com/javase/6/docs...classpath.html

Arne


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      12-28-2012
zyng wrote:
> zyng wrote:
>> OK. Thanks. But I can not make it work. In the script:
> > his_lib=/a/b


Forward slash hints you might be using a *nix style system.

>> my_lib=/c/d

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


"works": Meaning it picks up all JARs in that directory, yes?

>
>> 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.)


Obvious to whom?

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


What was that URL again?

.... windows/ ...

--
Lew
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      12-29-2012
On Fri, 28 Dec 2012 09:07:39 -0800 (PST), zyng <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>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).

--
Roedy Green Canadian Mind Products http://mindprod.com
Students who hire or con others to do their homework are as foolish
as couch potatoes who hire others to go to the gym for them.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      12-30-2012
On Fri, 28 Dec 2012 09:07:39 -0800 (PST), zyng <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>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.
--
Roedy Green Canadian Mind Products http://mindprod.com
Students who hire or con others to do their homework are as foolish
as couch potatoes who hire others to go to the gym for them.
 
Reply With Quote
 
John L.
Guest
Posts: n/a
 
      12-30-2012
On Friday, December 28, 2012 12:07:39 PM UTC-5, zyng wrote:
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.classpath file instead of the CLASSPATH Environment variable. dontspammenow@yahoo.com Java 2 03-02-2008 08:19 AM
Java Classpath - Simple Question RalphLeon Java 3 08-03-2007 06:56 PM
problem compiling project, classpath in xml ".classpath" "<classpathentry...>" jameshanley39@yahoo.co.uk Java 2 03-02-2007 12:37 PM
while using javac -classpath some.jar some.java (Where does classpath get stored?) Gabe Java 3 08-27-2004 07:02 PM
CLASSPATH, -cp and -classpath misunderstanding? Flip Java 3 02-09-2004 10:09 PM



Advertisments