export PATH=/usr/lib/jvm/jdk1.7.0_60/bin:$PATH
在系统范围的/etc/bash.bashrc文件中.
由于某些原因,这不起作用,所以我使用:
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_60
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
最初这似乎工作得很好,除了现在sudo,ls,发现,其他一切都不再起作用了.
然后我试图擦除这些行并重新启动系统,但命令不可用;错误是:
Command 'sudo' is available in '/usr/bin/sudo'
The command Could not be located because '/usr/bin' is not included in the PATH environment variable.
sudo: command not found
为了解决这个问题,我在/etc/bash.bashrc中复制了/ etc / environment的内容,添加了一行export PATH = $PATH:/usr/lib/jvm/jdk1.7.0_60/bin然后输入source / etc / bash .bashrc中.
同样,一切正常,但只在一个终端窗口而不是重启后.
我尝试了其他的东西,目前在/etc/bash.bashrc的末尾有以下几行:
export PATH=$PATH:/usr/lib/jvm/jdk1.7.0_60/bin/
export JAVA_HOME=$JAVA_HOME:/usr/lib/jvm/jdk1.7.0_60/bin/java/
但我必须在所有终端窗口中键入source / etc / environment和source /etc/bash.bashrc来获取java和命令.这就像我的改变不是永久性的.
目前,清除终端窗口中echo $PATH的结果是:
/usr/lib/jvm/jdk1.7.0_60/bin/
在源/ etc / environment之后它变成:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
最后,在源/etc/bash.bashrc之后它是:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.7.0_60/bin/
完整的bash.bashrc文件:
# System-wide .bashrc file for interactive bash(1) shells.
# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# check the window size after each command and, if necessary,
# update the values of LInes and COLUMNS.
shopt -s checkwinsize
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, overwrite the one in /etc/profile)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$'
# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
# ;;
#*)
# ;;
#esac
# enable bash completion in interactive shells
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi
# sudo hint
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
case " $(groups) " in *\ admin\ *)
if [ -x /usr/bin/sudo ]; then
cat <<-EOF
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
EOF
fi
esac
fi
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle {
# check because c-n-f Could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/bin/python /usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/bin/python /usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not found\n" "$1" >&2
return 127
fi
}
fi
export PATH=$PATH:/usr/lib/jvm/jdk1.7.0_60/bin/
export JAVA_HOME=$JAVA_HOME:/usr/lib/jvm/jdk1.7.0_60/bin/java/
有人可以帮帮我吗?我在Ubuntu 12.04 LTS下
解决方法:
尝试将bash.bashrc恢复为默认设置,然后在〜/ .bashrc文件中编辑PATH的本地副本.
换句话说,把最后两行:
export PATH=$PATH:/usr/lib/jvm/jdk1.7.0_60/bin/
export JAVA_HOME=$JAVA_HOME:/usr/lib/jvm/jdk1.7.0_60/bin/java/
在你的〜/ .bashrc文件而不是/etc/bash.bashrc中.您可能必须重新启动才能进行更改.
如果可行,并且您仍希望更改在系统范围内,则在/ etc / environment中附加PATH变量以获取Java路径.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。