当前位置: 技术问答>linux和unix
我想把JDK的环境变量加到系统中,可是按下面的方法修改/etc/profile后,重起N次都不生效?
来源: 互联网 发布时间:2015-06-18
本文导语: # /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=$PAT...
# /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
PATH=$PATH
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
export JAVA_HOME="/opt/JBuilder9/jdk1.4/"
export CLASSPATH=":$"JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar"
export PATH="$PATH:$JAVA_HOME/bin"
重起后我在终端中还用env、export命令,显示出的变量都是默认的?
路径我肯定没输错?????
# 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
PATH=$PATH
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
export JAVA_HOME="/opt/JBuilder9/jdk1.4/"
export CLASSPATH=":$"JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar"
export PATH="$PATH:$JAVA_HOME/bin"
重起后我在终端中还用env、export命令,显示出的变量都是默认的?
路径我肯定没输错?????
|
给个bash_profile的例子参考:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
QTDIR=/usr/lib/qt-2.3.0
JAVA_HOME=/usr/java/j2sdk1.4.0_01
LD_LIBRARY_PATH=/usr/lib/qt-2.3.0/lib:/usr/local/pgsql/lib:/opt/gtk/lib
PATH=$QTDIR/bin:/usr/local/gvd/bin:/usr/local/pgsql/bin:/opt/gtk/bin:$JAVA_HOME/bin:$JAVA_HOME/lib:/usr/local/sbin:/usr/sbin:/sbin:$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"
export QTDIR JAVA_HOME LD_LIBRARY_PATH USERNAME BASH_ENV PATH
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
QTDIR=/usr/lib/qt-2.3.0
JAVA_HOME=/usr/java/j2sdk1.4.0_01
LD_LIBRARY_PATH=/usr/lib/qt-2.3.0/lib:/usr/local/pgsql/lib:/opt/gtk/lib
PATH=$QTDIR/bin:/usr/local/gvd/bin:/usr/local/pgsql/bin:/opt/gtk/bin:$JAVA_HOME/bin:$JAVA_HOME/lib:/usr/local/sbin:/usr/sbin:/sbin:$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"
export QTDIR JAVA_HOME LD_LIBRARY_PATH USERNAME BASH_ENV PATH
|
vi /etc/profile
####add####
export JAVA_HOME=/usr/java/j2sdk1.4.0_01
export PATH=$PATH :$JAVA_HOME/bin
####:wq,exit
source /etc/profile
ok
####add####
export JAVA_HOME=/usr/java/j2sdk1.4.0_01
export PATH=$PATH :$JAVA_HOME/bin
####:wq,exit
source /etc/profile
ok
|
添加PATH那一行前的export去掉试试。
我组天刚做过,没有问题啊。
我组天刚做过,没有问题啊。