Solved

how to set classpath solaris /linux?

Posted on 2008-10-28
13
3,038 Views
Last Modified: 2013-12-27
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?

0
Comment
Question by:anup001
  • 8
  • 4
13 Comments
 
LVL 22

Expert Comment

by:blu
ID: 22827695
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
 

Author Comment

by:anup001
ID: 22832340
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
 

Author Comment

by:anup001
ID: 22832394
I cannot see java -version command.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 22

Expert Comment

by:blu
ID: 22832402
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
 

Author Comment

by:anup001
ID: 22832405
i can seee echo $PATH having some path. Where can i edit this path?
0
 

Author Comment

by:anup001
ID: 22832414
how do i set classpath from commandline then?
0
 

Author Comment

by:anup001
ID: 22832429
>>export JAVA_HOME=/usr/jdk1510/jdk1.5.0_10/bin/java
>> java -version
bash: java: command not found
>> 
0
 

Author Comment

by:anup001
ID: 22832433
why am i getting command nto found?
0
 
LVL 22

Accepted Solution

by:
blu earned 500 total points
ID: 22832504
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
 

Author Comment

by:anup001
ID: 22832642
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
 
LVL 22

Expert Comment

by:blu
ID: 22832779
With bash, you can place the commands in the file ".profile" (note the leading dot) in your home directory on the target system.
0
 

Author Comment

by:anup001
ID: 22833100
thanks!
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 22833103
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

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to have a cron job run until a condition is met 12 63
Coding C# in Linux 8 60
SCP a file to multiple machines using a script 4 43
awk sed 8 39
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

813 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

11 Experts available now in Live!

Get 1:1 Help Now