how to set classpath solaris /linux?

i ahe read several articles on how to set class path in solaris and java. Whcih file do i edit to set the java class path for all users? i need ot be able to see the java version using the java command form anywhere. Also hwo do is ee the java_home in env. How do i know which shell i am using?

anup001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brian UtterbackPrinciple Software EngineerCommented:
That's a lot of questions packed into one. The easiest first: You can try doing
"echo $SHELL" and see what you get. if that doesn't work, then do this:

echo $$
The above will give you the process number of your shell. Then run "ps -ef | grep pid" where pid is the process number. This
will print out the shell process name.

As far as setting the class path for all users, that generally isn't done. It is more typical to have a script to run any particular java command, and to set the classpath in the java command line in the script.

I am not sure what you are asking about the java version.
0
anup001Author Commented:
this si teh bask shell i ahve

root 14160 14140   0 07:35:50 pts/2       0:00 ps -ef
    root 14161 14140   0 07:35:50 pts/2       0:00 grep 14140
    root 14140 14138   0 07:35:13 pts/2       0:00 -bash



I need to set java class path so i can run java programs from anywhere not juust the java bin directory. How do I put it in the startup or intialization script. I remember its somehtng like .profile?
0
anup001Author Commented:
I cannot see java -version command.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Brian UtterbackPrinciple Software EngineerCommented:
You usually want to set the classpath from the command line. The java program itself will redirect the standard class libraries to point to the JAVA Home from which it runs. I think you are trying to go about this the wrong way.
0
anup001Author Commented:
i can seee echo $PATH having some path. Where can i edit this path?
0
anup001Author Commented:
how do i set classpath from commandline then?
0
anup001Author Commented:
>>export JAVA_HOME=/usr/jdk1510/jdk1.5.0_10/bin/java
>> java -version
bash: java: command not found
>> 
0
anup001Author Commented:
why am i getting command nto found?
0
Brian UtterbackPrinciple Software EngineerCommented:
You need to either run the java command by giving the whole path name, or add the java directory to the PATH variable.

/usr/jdk1510/jdk1.5.0_10/bin/java -version

or

PATH=$PATH:/usr/jdk1510/jdk1.5.0_10/bin
export PATH
java -version
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anup001Author Commented:
prefetc. Thansk a lot , one last question. If i use these exprt commands to set the paths, is this a permanemt path setting or i ned to do export everytim i ssh ?
0
Brian UtterbackPrinciple Software EngineerCommented:
With bash, you can place the commands in the file ".profile" (note the leading dot) in your home directory on the target system.
0
anup001Author Commented:
thanks!
0
omarfaridCommented:
if you want to set it for all users then use system wide files like

/etc/profile (for sh, ksh, bash users)

or

/etc/.login (csh users)

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.