Adding Java to my path in the .bash_profile file ....
Hey, i am having trouble adding java to my path using the .bash_profile file so i don't have to enter export PATH=PATH:/usr/java/j2sdk1.4.2_04/bin every time i want to use the java command line tools. Here is what the file looks like now.
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin BASH_ENV=$HOME/.bashrc USERNAME="root" export USERNAME BASH_ENV PATH :/usr/java/j2sdk1.4.2_04/bin could someone tell me what i am doing wrong. thx, jmax24 |
Your adding your ammended path variable AFTER it exports it..... Does no good. It has to be before the line:
export USERNAME BASH_ENV PATH add to this line: PATH=$PATH:$HOME/bin so it reads: PATH=$PATH:$HOME/bin:/usr/java/j2sdk1.4.2_04/bin Thats kind of a wierd looking bash_profile as far as the PATH goes... Makes me wonder what $HOME equals......... What Distro are you using? What does '/etc/bashrc' look like? I always run as root so I don't mess with home files..... I do everything global..... :eek: |
i am running redhat 8, and i also run as root, i do have a user called Jeff though.
here is what the bashrc file looks like # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi |
Oh... I was talking about "/etc/bashrc".. And actually, it's "/etc/profile" that contains the global paths..... If you want the java directory to be in your path for EVERY user than modify '/etc/profile'. If you just want it to be there for a certain user, then modify the '~/.bash_profile'...... My earlier suggestion still holds for how you should change it.....
|
here is my /etc/profile file, where should i put it in here
# /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi fi } # Path manipulation if [ `id -u` = 0 ]; then pathmunge /sbin pathmunge /usr/sbin pathmunge /usr/local/sbin fi pathmunge /usr/X11R6/bin after unset pathmunge # No core files by default ulimit -S -c 0 > /dev/null 2>&1 USER="`id -un`" LOGNAME=$USER MAIL="/var/spool/mail/$USER" HOSTNAME=`/bin/hostname` HISTSIZE=1000 if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then INPUTRC=/etc/inputrc fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then . $i fi done unset i |
Well, I have Fedora on another partition and mine looks the same. I don't know why they mess with all these variables... I used to program basic as a kid so I'm familiar with it but not really at the same time... Your ~/bash_profile was easier to read.... I would do this for /etc/profile: This is just the relevant section...
# Path manipulation if [ `id -u` = 0 ]; then pathmunge /sbin pathmunge /usr/sbin pathmunge /usr/local/sbin pathmunge /usr/java/j2sdk1.4.2_04/bin fi That should take care of root having access..... Then for "/home/jeff/.bash_profile" I would: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin:/usr/java/j2sdk1.4.2_04/bin BASH_ENV=$HOME/.bashrc USERNAME="root" export USERNAME BASH_ENV PATH Or you could just copy that file and paste it into roots folder as well..... |
All times are GMT -5. The time now is 10:44 AM. |