Solved

Setting classpath and executing shell script

Posted on 2004-08-23
6
4,686 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

751 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