Solved

Setting classpath and executing shell script

Posted on 2004-08-23
6
4,337 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 18

Expert Comment

by:liddler
Comment Utility
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
Comment Utility
Ok! thnx for the clarification.. Is there any other alternative to making the change in .profile ???

thnx
0
 
LVL 18

Expert Comment

by:liddler
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now