Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting classpath and executing shell script

Posted on 2004-08-23
6
Medium Priority
?
5,071 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
  • 3
  • 3
6 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 400 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month11 days, 2 hours left to enroll

885 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