LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-19-2004, 09:53 PM   #1
jmax24
Member
 
Registered: Apr 2004
Posts: 39

Rep: Reputation: 15
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
 
Old 04-19-2004, 10:18 PM   #2
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
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.....
 
Old 04-20-2004, 12:07 AM   #3
jmax24
Member
 
Registered: Apr 2004
Posts: 39

Original Poster
Rep: Reputation: 15
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
 
Old 04-20-2004, 12:16 AM   #4
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
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.....
 
Old 04-20-2004, 12:20 AM   #5
jmax24
Member
 
Registered: Apr 2004
Posts: 39

Original Poster
Rep: Reputation: 15
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
 
Old 04-20-2004, 01:14 PM   #6
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
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.....
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot load .so file from java library path whalesurf Linux - Software 1 07-24-2006 11:43 AM
Adding Java to root users PATH? infornography Linux - Newbie 5 05-26-2005 07:49 AM
adding java jdk to path snecklifter Linux - Newbie 4 11-01-2004 02:58 PM
Adding Java to my environment path? C8H10N4O2 Linux - Software 6 04-19-2004 01:38 PM
Adding a file to the path in etc/profile zzzt Linux - Newbie 3 10-24-2003 03:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:33 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
Open Source Consulting | Domain Registration