使用openSUSE的,我下载了jdk1.6.0_24甲骨文的RPM,我想设置Java家居环境变量/usr/java/jdk1.6.0_24但在/ etc/alternatives系统无法自动检测到这个安装的JDK。更新替代品,或者其他什么都找不到jdk。的Bash shell脚本:如何设置JAVA_HOME环境变量
所以,我想手动检测JAVA家在bash脚本。
如果我运行这个命令:sudo的发现在/ usr -name 'JDK1.6 *',我得到这样的结果:
/usr/java/jdk1.6.0_24
如何导致到一个环境变量管?我想这样做
#!/bin/bash
read in JAVA_HOME var from a file
if file doesnt exist
sudo find /usr -name 'jdk1.6*'
prompt user for which jdk is correct
set that choice to a variable
add the JDK to alternatives if it is missing
save variable to a file and dont prompt next time
set the alternatives java choice
fi
echo $JAVA_HOME
为什么你需要sudo使用find?如果您的用户标识无法读取它,则不应将该值用于JAVA_HOME。 – 2011-03-25 19:59:11
你的权利。把我的所有剧本都拿出来了。谢谢。 – djangofan 2011-03-25 20:29:46