Solved

Setting classpath and executing shell script

Posted on 2004-08-23
6
4,519 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 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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 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.:

770 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