LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-09-2007, 10:40 AM   #1
Raakh
Member
 
Registered: May 2007
Posts: 128

Rep: Reputation: 15
setting path and classpath


I am setting path like:
export JAVA_HOME=/usr/java/jdk1.6.0_01/bin
export PATH=$JAVA_HOME;$PATH

but when am relogging then I have to reset path again. how can i set the path or classpath permanently

thanks & best regards
 
Old 07-09-2007, 10:48 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
What shell are you using? Bash?

If so, you should add those lines to ${HOME}/.bash_profile or ${HOME}/.bashrc

If you want other users to also benefit from these settings, add them to /etc/bashrc or /etc/profile instead (requires root access).
 
Old 07-09-2007, 11:07 AM   #3
Raakh
Member
 
Registered: May 2007
Posts: 128

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by timmeke
What shell are you using? Bash?

If so, you should add those lines to ${HOME}/.bash_profile or ${HOME}/.bashrc

If you want other users to also benefit from these settings, add them to /etc/bashrc or /etc/profile instead (requires root access).

[root@bhinternationalltd etc]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin://sbin://bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
[root@bhinternationalltd etc]# ${HOME}/.bash_profile
-bash: /root/.bash_profile: Permission denied
[root@bhinternationalltd etc]# ${HOME}/.bashrc
-bash: /root/.bashrc: Permission denied
[root@bhinternationalltd etc]# ${HOME}/etc/bashrc
-bash: /root/etc/bashrc: No such file or directory
[root@bhinternationalltd etc]#
 
Old 07-09-2007, 12:18 PM   #4
Raakh
Member
 
Registered: May 2007
Posts: 128

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Raakh
[root@bhinternationalltd etc]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin://sbin://bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
[root@bhinternationalltd etc]# ${HOME}/.bash_profile
-bash: /root/.bash_profile: Permission denied
[root@bhinternationalltd etc]# ${HOME}/.bashrc
-bash: /root/.bashrc: Permission denied
[root@bhinternationalltd etc]# ${HOME}/etc/bashrc
-bash: /root/etc/bashrc: No such file or directory
[root@bhinternationalltd etc]#

Why permission denied message appear and how can I remove it
 
Old 07-10-2007, 02:39 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
I was telling you to edit the .bash_profile file in your user's home directory.
So ${HOME}/.bash_profile and ${HOME}/.bashrc are OK as paths if you want to run them, but you should open
them in an editor instead.

${HOME}/etc/bashrc is an invalid path: ${HOME} variable contains your home directory (ie /home/user or /root for the root user), but this directory probably does not have a subdirectory called "etc". Instead, you need /etc/bashrc (absolute path, not relative to ${HOME}). To see what $HOME contains, just echo it:
Code:
echo ${HOME}
Finally, executing a bash_profile or bashrc file is no good, as the environment settings made by the commands inside the files are undone once the execution is completed. Instead, you need to "source" the files, using the "source" or "." commands, as in the following examples:
Code:
. ${HOME}/.bashrc
source ${HOME}/.bash_profile
As for the permission denied issue. Most likely, the files are not set to be executed (x permission). You can check this by executing
Code:
ls -l ${HOME}/.bashrc ${HOME}/.bash_profile
or similar for the files in /etc.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CentOS 4.4 saving PATH, CLASSPATH variables Thor Red Hat 2 11-25-2006 09:55 AM
How to set PATH and CLASSPATH environment variables bronko Linux - Newbie 2 12-20-2003 12:13 PM
set up path,classpath in linux(slaware9) for java Manjula.S Linux - Software 5 10-07-2003 12:38 AM
setting java classpath... brutal_brad Linux - Newbie 7 09-21-2003 03:52 PM
setting CLASSPATH variable gabadoo Linux - Newbie 7 01-21-2002 05:24 PM


All times are GMT -5. The time now is 12:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration