permaculture playing cards
The moose likes Java in General and the fly likes Shell script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Shell script" Watch "Shell script" New topic

Shell script

anirban dando

Joined: May 12, 2005
Posts: 4
I am trying to execute a shell script with path set to Java 1.3 and classapth set to some custom java classes. After runing the script the command java -version is showing that I am at version 1.1.8 which is the default one and also the classpath is not set. Where am I going worng ?? .. Interestingly the script is showing as Java 1.3 when I queried PATH in the script. Please check my script below -

export PATH="/usr/java131/bin:$PATH"
#export PATH
java -version

when the script is run --


java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1)
Classic VM (build 1.3.1, J2RE 1.3.1 IBM AIX build ca131ifx-20040721a SR7P (JIT enabled: jitc))

Where Am I doing wrong ?? .. Please help me ..

Henry Wong

Joined: Sep 28, 2004
Posts: 20175

Shellscripts are executed in a subshell -- so you did change it, but the changes does not take.

It has been years since I used ksh, but for csh or bash, the "source" or "." command will run the script with the current shell.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
anirban dando

Joined: May 12, 2005
Posts: 4
Thanks a lot Henry.. It worked out .. U saved my day .
I agree. Here's the link:
subject: Shell script
It's not a secret anymore!