Linux下多个jdk引发的问题

在linux中执行javac时报如下错误:

libgcj-javac-placeholder.sh

This script is a placeholder for the /usr/bin/javac
master link required by jpackage.org conventions.  libgcj's
rmiregistry, rmic and jar tools are now slave symlinks to these
masters, and are managed by the alternatives(8) system.

This change was necessary because the rmiregistry, rmic and jar tools
installed by previous versions of libgcj conflicted with symlinks
installed by jpackage.org JVM packages.

This script was designed to be overridden by the supported RHEL3 SDK
packages, java-1.4.2-bea-devel and java-1.4.2-ibm-devel.  It is
installed as an alternative symlink as /usr/bin/javac.  It will
override a third-party (non-RHEL3) SDK's javac command if the SDK's
bin directory is listed after /usr/bin in PATH.  In that case, it is
recommended that the third-party SDK's bin directory be listed first
in PATH instead.

/usr/bin/javac: line 22: exec: gcj: not found 

经过一番搜索发现,问题是在系统中安装了多个jdk。主要解决方法有两种:

简单方法:修改环境变量PATH,将JAVA_HOME/bin设为第一位。

较为复杂的方法:

$ java -version
... placeholder message ...
$ su -
# alternatives --remove java /usr/share/java/libgcj-java-placeholder.sh
# alternatives --remove javac /usr/share/java/libgcj-java-placeholder.sh
# alternatives --remove jar /usr/bin/fastjar
# alternatives --remove jar.1.gz /usr/share/man/man1/fastjar.1.gz
# cd /usr/bin
# ln -s /usr/java/jdk/bin/java java
... also set the links for javac etc ...
# exit
$ java -version
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)


第二个方法是直接删除造成初始java环境混乱的Package

Quote:
libgcj-devel-3.4.2-6.fc3
libgcj-3.4.2-6.fc3

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值