当前位置: 技术问答>linux和unix
Help! I have set the java path as you say, but it do not work!(waiting online)
来源: 互联网 发布时间:2015-02-07
本文导语: I have set the java path as follow: vi /etc/profile # /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($|...
I have set the java path as follow:
vi /etc/profile
# /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
JAVA_HOME=/usr/java/j2sdk1.4.1
export JAVA_HOME
CLASSPATH=/usr/java/j2sdk1.4.1/lib:/usr/java/j2sdk1.4.1/jre/lib
export CLASSPATH
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jar/bin
export PATH
if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
pathmunge /usr/X11R6/bin after
///////////////////////////////////////////////////////////////////////
but it doesn't work !
if i input: java -version
the return is:
java version 1.3.1
it is the red hat's origina one
some one can tell me is there something wrong !
thank you very ver much:
vi /etc/profile
# /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
JAVA_HOME=/usr/java/j2sdk1.4.1
export JAVA_HOME
CLASSPATH=/usr/java/j2sdk1.4.1/lib:/usr/java/j2sdk1.4.1/jre/lib
export CLASSPATH
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jar/bin
export PATH
if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
pathmunge /usr/X11R6/bin after
///////////////////////////////////////////////////////////////////////
but it doesn't work !
if i input: java -version
the return is:
java version 1.3.1
it is the red hat's origina one
some one can tell me is there something wrong !
thank you very ver much:
|
原因出在
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jar/bin
上,
你是把$JAVA_HOME/bin放在系统$PATH之后,
那系统在寻找java的时候,肯定先在原来的PATH中
找到1.3.1的可执行文件。
解决方法:把$JAVA_HOME/bin放前面,
象下面一样。
PATH=$JAVA_HOME/bin:$JAVA_HOME/jar/bin:$PATH
其它的环境变量也有同样的问题,注意一下。
good luck
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jar/bin
上,
你是把$JAVA_HOME/bin放在系统$PATH之后,
那系统在寻找java的时候,肯定先在原来的PATH中
找到1.3.1的可执行文件。
解决方法:把$JAVA_HOME/bin放前面,
象下面一样。
PATH=$JAVA_HOME/bin:$JAVA_HOME/jar/bin:$PATH
其它的环境变量也有同样的问题,注意一下。
good luck
|
楼主:
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
中,if [ "$2" = "after" ] ; then
的“;”号何解?
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
中,if [ "$2" = "after" ] ; then
的“;”号何解?
|
to trans318:
the ';' is similar to this:
# clear; who am i; ls
the ';' is similar to this:
# clear; who am i; ls