原文地址:http://blog.csdn.net/HuDon/archive/2007/05/30/1631959.aspx

 
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky tv2.0]# java
(转)可替换系统(alternatives system)的应用浅议Usage: gij [OPTION] ... CLASS [ARGS] ...
(转)可替换系统(alternatives system)的应用浅议          to invoke CLASS.main, or
(转)可替换系统(alternatives system)的应用浅议       gij 
-jar [OPTION] ... JARFILE [ARGS] ...
(转)可替换系统(alternatives system)的应用浅议          to execute a jar file
(转)可替换系统(alternatives system)的应用浅议Try `gij 
--help' for more information.
(转)可替换系统(alternatives system)的应用浅议

于是:
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky tv2.0]# which java
(转)可替换系统(alternatives system)的应用浅议
/usr/bin/java
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky software]# ls 
/usr/bin/java -l
(转)可替换系统(alternatives system)的应用浅议lrwxrwxrwx 
1 root root 22 01-15 21:23 /usr/bin/java -> /etc/alternatives/java
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky software]# ll 
/etc/alternatives/java
(转)可替换系统(alternatives system)的应用浅议lrwxrwxrwx 
1 root root 35 05-10 13:48 /etc/alternatives/java -> /usr/lib/jvm/jre-1.4.2-gcj/bin/java
(转)可替换系统(alternatives system)的应用浅议
这说明java是受fc下同一软件的版本控制工具alternatives控制的,下面就是用这个工具将系统自带的GNU的java换成Sun的java版本;
查看alternatives的帮助;
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky software]# alternatives --help
(转)可替换系统(alternatives system)的应用浅议替换选择(alternatives)的版本 
1.3.30 - 版权 (C) 1997-2000 Red Hat, Inc.
(转)可替换系统(alternatives system)的应用浅议在 GNU 公共许可的条款下,本软件可以被*发行。
(转)可替换系统(alternatives system)的应用浅议
(转)可替换系统(alternatives system)的应用浅议用法:alternatives 
--install <link> <name> <path> <priority>
(转)可替换系统(alternatives system)的应用浅议                    [
--initscript <service>]
(转)可替换系统(alternatives system)的应用浅议                    [
--slave <link> <name> <path>]*
(转)可替换系统(alternatives system)的应用浅议       alternatives 
--remove <name> <path>
(转)可替换系统(alternatives system)的应用浅议       alternatives 
--auto <name>
(转)可替换系统(alternatives system)的应用浅议       alternatives 
--config <name>
(转)可替换系统(alternatives system)的应用浅议       alternatives 
--display <name>
(转)可替换系统(alternatives system)的应用浅议       alternatives 
--set <name> <path>
(转)可替换系统(alternatives system)的应用浅议
(转)可替换系统(alternatives system)的应用浅议公用选项:
--verbose --test --help --usage --version
(转)可替换系统(alternatives system)的应用浅议                
--altdir <directory> --admindir <directory>
(转)可替换系统(alternatives system)的应用浅议
并通过实验得到,install是安装同一软件的不同版本,remove则是移出某个版本,config则是选择当前系统使用那个版本,而display则是显示当前使用的版本,auto则是更改当前的状态为自动判断,也就是可以恢复GNU版本java的一个参数;
下面先安装jre1.5.0_09,此版本可以到sun的公司网站上下得;
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky software]# rpm -ivh jre-1_5_0_09-linux-i586.rpm 
(转)可替换系统(alternatives system)的应用浅议Preparing...                ########################################### [
100%]
(转)可替换系统(alternatives system)的应用浅议   
1:jre                    ########################################### [100%]
(转)可替换系统(alternatives system)的应用浅议
检查是否安装成功:
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky software]# /usr/java/jre1.5.0_09/bin/java
(转)可替换系统(alternatives system)的应用浅议Usage: java [
-options] class [args...]
(转)可替换系统(alternatives system)的应用浅议           (to execute a 
class)
(转)可替换系统(alternatives system)的应用浅议   or  java [
-options] -jar jarfile [args...]
(转)可替换系统(alternatives system)的应用浅议           (to execute a jar file)
(转)可替换系统(alternatives system)的应用浅议
(转)可替换系统(alternatives system)的应用浅议
where options include:
(转)可替换系统(alternatives system)的应用浅议    
-d32          use a 32-bit data model if available
(转)可替换系统(alternatives system)的应用浅议
(转)可替换系统(alternatives system)的应用浅议    
-d64          use a 64-bit data model if available
(转)可替换系统(alternatives system)的应用浅议    
-client       to select the "client" VM
(转)可替换系统(alternatives system)的应用浅议    
-server       to select the "server" VM
(转)可替换系统(alternatives system)的应用浅议    
-hotspot      is a synonym for the "client" VM  [deprecated]
(转)可替换系统(alternatives system)的应用浅议                  The 
default VM is client.
(转)可替换系统(alternatives system)的应用浅议                  
(转)可替换系统(alternatives system)的应用浅议    
-cp <class search path of directories and zip/jar files>
(转)可替换系统(alternatives system)的应用浅议    
-classpath <class search path of directories and zip/jar files>
(转)可替换系统(alternatives system)的应用浅议                  A : separated list of directories, JAR archives,
(转)可替换系统(alternatives system)的应用浅议                  and ZIP archives to search 
for class files.
(转)可替换系统(alternatives system)的应用浅议    
-D<name>=<value>
(转)可替换系统(alternatives system)的应用浅议                  
set a system property
(转)可替换系统(alternatives system)的应用浅议    
-verbose[:class|gc|jni]
(转)可替换系统(alternatives system)的应用浅议                  enable verbose output
(转)可替换系统(alternatives system)的应用浅议    
-version      print product version and exit
(转)可替换系统(alternatives system)的应用浅议    
-version:<value>
(转)可替换系统(alternatives system)的应用浅议                  require the specified version to run
(转)可替换系统(alternatives system)的应用浅议    
-showversion  print product version and continue
(转)可替换系统(alternatives system)的应用浅议    
-jre-restrict-search | -jre-no-restrict-search
(转)可替换系统(alternatives system)的应用浅议                  include
/exclude user private JREs in the version search
(转)可替换系统(alternatives system)的应用浅议    
-? -help      print this help message
(转)可替换系统(alternatives system)的应用浅议    
-X            print help on non-standard options
(转)可替换系统(alternatives system)的应用浅议    
-ea[:<packagename>...|:<classname>]
(转)可替换系统(alternatives system)的应用浅议    
-enableassertions[:<packagename>...|:<classname>]
(转)可替换系统(alternatives system)的应用浅议                  enable assertions
(转)可替换系统(alternatives system)的应用浅议    
-da[:<packagename>...|:<classname>]
(转)可替换系统(alternatives system)的应用浅议    
-disableassertions[:<packagename>...|:<classname>]
(转)可替换系统(alternatives system)的应用浅议                  disable assertions
(转)可替换系统(alternatives system)的应用浅议    
-esa | -enablesystemassertions
(转)可替换系统(alternatives system)的应用浅议                  enable system assertions
(转)可替换系统(alternatives system)的应用浅议    
-dsa | -disablesystemassertions
(转)可替换系统(alternatives system)的应用浅议                  disable system assertions
(转)可替换系统(alternatives system)的应用浅议    
-agentlib:<libname>[=<options>]
(转)可替换系统(alternatives system)的应用浅议                  load native agent library 
<libname>, e.g. -agentlib:hprof
(转)可替换系统(alternatives system)的应用浅议                    see also, 
-agentlib:jdwp=help and -agentlib:hprof=help
(转)可替换系统(alternatives system)的应用浅议    
-agentpath:<pathname>[=<options>]
(转)可替换系统(alternatives system)的应用浅议                  load native agent library by full pathname
(转)可替换系统(alternatives system)的应用浅议    
-javaagent:<jarpath>[=<options>]
(转)可替换系统(alternatives system)的应用浅议                  load Java programming language agent, see java.lang.instrument
(转)可替换系统(alternatives system)的应用浅议
出现这些字样,表明jre安装成功了;
接着,使用alternatives工具增加这个版本;
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky software]# alternatives --install /usr/bin/java java /usr/java/jre1.5.0_09/bin/java 300
配置:
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky software]# alternatives --config java
(转)可替换系统(alternatives system)的应用浅议
(转)可替换系统(alternatives system)的应用浅议共有 
2 个程序提供“java”。
(转)可替换系统(alternatives system)的应用浅议
(转)可替换系统(alternatives system)的应用浅议  选择    命令
(转)可替换系统(alternatives system)的应用浅议
-----------------------------------------------
(转)可替换系统(alternatives system)的应用浅议
*  1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
(转)可替换系统(alternatives system)的应用浅议   
2           /usr/java/jre1.5.0_09/bin/java
(转)可替换系统(alternatives system)的应用浅议
(转)可替换系统(alternatives system)的应用浅议按 Enter 来保存当前选择[
+],或键入选择号码:2
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky software]# java
(转)可替换系统(alternatives system)的应用浅议Usage: java [
-options] class [args...]
(转)可替换系统(alternatives system)的应用浅议           (to execute a 
class)
(转)可替换系统(alternatives system)的应用浅议   or  java [
-options] -jar jarfile [args...]
(转)可替换系统(alternatives system)的应用浅议           (to execute a jar file)
(转)可替换系统(alternatives system)的应用浅议
(转)可替换系统(alternatives system)的应用浅议
where options include:
(转)可替换系统(alternatives system)的应用浅议    
-d32          use a 32-bit data model if available
(转)可替换系统(alternatives system)的应用浅议
(转)可替换系统(alternatives system)的应用浅议    
-d64          use a 64-bit data model if available
(转)可替换系统(alternatives system)的应用浅议    
-client       to select the "client" VM
(转)可替换系统(alternatives system)的应用浅议    
-server       to select the "server" VM
(转)可替换系统(alternatives system)的应用浅议    
-hotspot      is a synonym for the "client" VM  [deprecated]
(转)可替换系统(alternatives system)的应用浅议                  The 
default VM is client.
(转)可替换系统(alternatives system)的应用浅议                  
(转)可替换系统(alternatives system)的应用浅议    
-cp <class search path of directories and zip/jar files>
(转)可替换系统(alternatives system)的应用浅议    
-classpath <class search path of directories and zip/jar files>
(转)可替换系统(alternatives system)的应用浅议                  A : separated list of directories, JAR archives,
(转)可替换系统(alternatives system)的应用浅议                  and ZIP archives to search 
for class files.
(转)可替换系统(alternatives system)的应用浅议    
-D<name>=<value>
(转)可替换系统(alternatives system)的应用浅议                  
set a system property
(转)可替换系统(alternatives system)的应用浅议    
-verbose[:class|gc|jni]
(转)可替换系统(alternatives system)的应用浅议                  enable verbose output
(转)可替换系统(alternatives system)的应用浅议    
-version      print product version and exit
(转)可替换系统(alternatives system)的应用浅议    
-version:<value>
(转)可替换系统(alternatives system)的应用浅议                  require the specified version to run
(转)可替换系统(alternatives system)的应用浅议    
-showversion  print product version and continue
(转)可替换系统(alternatives system)的应用浅议    
-jre-restrict-search | -jre-no-restrict-search
(转)可替换系统(alternatives system)的应用浅议                  include
/exclude user private JREs in the version search
(转)可替换系统(alternatives system)的应用浅议    
-? -help      print this help message
(转)可替换系统(alternatives system)的应用浅议    
-X            print help on non-standard options
(转)可替换系统(alternatives system)的应用浅议    
-ea[:<packagename>...|:<classname>]
(转)可替换系统(alternatives system)的应用浅议    
-enableassertions[:<packagename>...|:<classname>]
(转)可替换系统(alternatives system)的应用浅议                  enable assertions
(转)可替换系统(alternatives system)的应用浅议    
-da[:<packagename>...|:<classname>]
(转)可替换系统(alternatives system)的应用浅议    
-disableassertions[:<packagename>...|:<classname>]
(转)可替换系统(alternatives system)的应用浅议                  disable assertions
(转)可替换系统(alternatives system)的应用浅议    
-esa | -enablesystemassertions
(转)可替换系统(alternatives system)的应用浅议                  enable system assertions
(转)可替换系统(alternatives system)的应用浅议    
-dsa | -disablesystemassertions
(转)可替换系统(alternatives system)的应用浅议                  disable system assertions
(转)可替换系统(alternatives system)的应用浅议    
-agentlib:<libname>[=<options>]
(转)可替换系统(alternatives system)的应用浅议                  load native agent library 
<libname>, e.g. -agentlib:hprof
(转)可替换系统(alternatives system)的应用浅议                    see also, 
-agentlib:jdwp=help and -agentlib:hprof=help
(转)可替换系统(alternatives system)的应用浅议    
-agentpath:<pathname>[=<options>]
(转)可替换系统(alternatives system)的应用浅议                  load native agent library by full pathname
(转)可替换系统(alternatives system)的应用浅议    
-javaagent:<jarpath>[=<options>]
(转)可替换系统(alternatives system)的应用浅议                  load Java programming language agent, see java.lang.instrument
(转)可替换系统(alternatives system)的应用浅议
如此,成功;
查看效果:
(转)可替换系统(alternatives system)的应用浅议[root@BlueSky software]# alternatives --display java
(转)可替换系统(alternatives system)的应用浅议java 
- 状态是手工。
(转)可替换系统(alternatives system)的应用浅议 链接目前指向 
/usr/java/jre1.5.0_09/bin/java
(转)可替换系统(alternatives system)的应用浅议
/usr/lib/jvm/jre-1.4.2-gcj/bin/java - 优先度 1420
(转)可替换系统(alternatives system)的应用浅议 从 keytool:
/usr/lib/jvm/jre-1.4.2-gcj/bin/keytool
(转)可替换系统(alternatives system)的应用浅议 从 rmiregistry:
/usr/lib/jvm/jre-1.4.2-gcj/bin/rmiregistry
(转)可替换系统(alternatives system)的应用浅议 从 jre_exports:
/usr/lib/jvm-exports/jre-1.4.2-gcj
(转)可替换系统(alternatives system)的应用浅议 从 jre:
/usr/lib/jvm/jre-1.4.2-gcj
(转)可替换系统(alternatives system)的应用浅议
/usr/java/jre1.5.0_09/bin/java - 优先度 300
(转)可替换系统(alternatives system)的应用浅议 从 keytool:(
null)
(转)可替换系统(alternatives system)的应用浅议 从 rmiregistry:(
null)
(转)可替换系统(alternatives system)的应用浅议 从 jre_exports:(
null)
(转)可替换系统(alternatives system)的应用浅议 从 jre:(
null)
(转)可替换系统(alternatives system)的应用浅议当前“最佳”版本是 
/usr/lib/jvm/jre-1.4.2-gcj/bin/java。
(转)可替换系统(alternatives system)的应用浅议
结论,alternaties这个工具还是不错的。。。

分类:

技术点:

相关文章: