Solved

Setting classpath and executing shell script

Posted on 2004-08-23
6
4,800 Views
Last Modified: 2013-12-27
Hi,

I am present setting the classpath for java on a Solaris machine as:

export CLASSPATH=/usr/java

While the above works fine, it lasts for only the current session and I would like to set it permanently into the environment. However the command

setenv CLASSPATH=/usr/java  gives me a cmd not found error..
set env CLASSPATH=/usr/java  executes ok but doenst do anything..

I tried a workaround by creating a shell script with the line
export CLASSPATH=/usr/java  but executing the script doenst seem to do anything either..

Any suggestions ??

TIA
0
Comment
Question by:sgaucho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 100 total points
ID: 11870634
Which shell are you using?

You need to set CLASSPATH in your profile for sh or ksh and in your .cshrc from csh

For sh or ksh
edit (or create) the .profile file in your home directory
add
CLASSPATH=$CLASSPATH:/usr/java
export CLASSPATH

for csh
setenv CLASSPATH /usr/java

Then save the file
for (k)sh
. ./.profile (there dots and a space)
for csh
source .cshrc

OR log in and out, the file will be read on every subsequeny login
0
 

Author Comment

by:sgaucho
ID: 11871651
Hi,

I have a bash$ and doing a ls-la give me the fwg:

bash-2.05$ ls -la
total 202
drwxr-xr-x  11 xpts298  other        512 Aug 23 14:46 .
drwxr-xr-x  11 root     root         512 Aug 19 13:03 ..
-rw-------   1 xpts298  other        258 Aug 19 17:21 .ICEauthority
-rw-------   1 xpts298  other         49 Aug 19 17:20 .Xauthority
-rw-------   1 xpts298  other       7851 Aug 23 14:47 .bash_history
drwxr-xr-x   9 xpts298  other        512 Aug 19 17:21 .dt
-rwxr-xr-x   1 xpts298  other       5111 Aug 19 13:03 .dtprofile
drwx------   4 xpts298  other        512 Aug 19 18:40 .gconf
drwx------   2 xpts298  other        512 Aug 19 18:40 .gconfd
drwx------   3 xpts298  other        512 Aug 19 13:06 .gnome
drwxr-xr-x   2 xpts298  other        512 Aug 19 13:03 .gnome-desktop
drwx------   5 xpts298  other        512 Aug 19 17:26 .gnome2
drwx------   2 xpts298  other        512 Aug 19 13:03 .gnome2_private
drwxr-xr-x   3 xpts298  other        512 Aug 19 13:03 .nautilus
-rw-r--r--   1 xpts298  other      70712 Aug 19 13:04 .xftcache

There is only a .dtprofile. Should I edit this ??

thanks,

0
 

Author Comment

by:sgaucho
ID: 11872391
Hi,

Sorry, didnt read the "create" part ! ok.. its working great. If you can pl answer my other question too i.e. regarding setting the Classpath via a shell script, I can close this question..

Thnx!
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 18

Expert Comment

by:liddler
ID: 11872527
Executing it in a shell script only makes the variable (CLASSPATH) validin that script, and the variable clears whenh the script ends, so it won't work
0
 

Author Comment

by:sgaucho
ID: 11872894
Ok! thnx for the clarification.. Is there any other alternative to making the change in .profile ???

thnx
0
 
LVL 18

Expert Comment

by:liddler
ID: 11873045
YOu can do something like:
create a script, start.sh
#!/bin/sh
CLASSPATH=/usr/java
export CLASSPATH
/path/to/java/program


This is a wrapper script, that starts another script / program as a child that inherits the variables from this parent script
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question