可替换系统(alternatives system)的应用浅议

 
[root@BlueSky tv2. 0 ]# java
Usage: gij [OPTION] ... CLASS [ARGS] ...
          to invoke CLASS.main, or
       gij 
- jar [OPTION] ... JARFILE [ARGS] ...
          to execute a jar file
Try `gij 
-- help '  for more information.

于是:
[root@BlueSky tv2. 0 ]# which java
/ usr / bin / java
[root@BlueSky software]# ls 
/ usr / bin / java  - l
lrwxrwxrwx 
1  root root  22   01 - 15   21 : 23   / usr / bin / java  ->   / etc / alternatives / java
[root@BlueSky software]# ll 
/ etc / alternatives / java
lrwxrwxrwx 
1  root root  35   05 - 10   13 : 48   / etc / alternatives / java  ->   / usr / lib / jvm / jre - 1.4 . 2 - gcj / bin / java
这说明java是受fc下同一软件的版本控制工具alternatives控制的,下面就是用这个工具将系统自带的GNU的java换成Sun的java版本;
查看alternatives的帮助;
[root@BlueSky software]# alternatives  -- help
替换选择(alternatives)的版本 
1.3 . 30   -  版权 (C)  1997 - 2000  Red Hat, Inc.
在 GNU 公共许可的条款下,本软件可以被自由发行。

用法:alternatives 
-- install  < link >   < name >   < path >   < priority >
                    [
-- initscript  < service > ]
                    [
-- slave  < link >   < name >   < path > ] *
       alternatives 
-- remove  < name >   < path >
       alternatives 
-- auto  < name >
       alternatives 
-- config  < name >
       alternatives 
-- display  < name >
       alternatives 
-- set   < name >   < path >

公用选项:
-- verbose  -- test  -- help  -- usage  -- version
                
-- altdir  < directory >   -- admindir  < directory >
并通过实验得到,install是安装同一软件的不同版本,remove则是移出某个版本,config则是选择当前系统使用那个版本,而display则是显示当前使用的版本,auto则是更改当前的状态为自动判断,也就是可以恢复GNU版本java的一个参数;
下面先安装jre1.5.0_09,此版本可以到sun的公司网站上下得;
[root@BlueSky software]# rpm  - ivh jre - 1_5_0_09 - linux - i586.rpm 
Preparing...                ########################################### [
100 % ]
   
1 :jre                    ########################################### [ 100 % ]
检查是否安装成功:
[root@BlueSky software]#  / usr / java / jre1. 5 .0_09 / bin / java
Usage: java [
- options]  class  [args...]
           (to execute a 
class )
   or  java [
- options]  - jar jarfile [args...]
           (to execute a jar file)

where  options include:
    
- d32          use a  32 - bit data model  if  available

    
- d64          use a  64 - bit data model  if  available
    
- client       to select the  " client "  VM
    
- server       to select the  " server "  VM
    
- hotspot       is  a synonym  for  the  " client "  VM  [deprecated]
                  The 
default  VM  is  client.
                  
    
- cp  < class  search path of directories and zip / jar files >
    
- classpath  < class  search path of directories and zip / jar files >
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search 
for   class  files.
    
- D < name >=< value >
                  
set  a system property
    
- verbose[: class | gc | jni]
                  enable verbose output
    
- version      print product version and exit
    
- version: < value >
                  require the specified version to run
    
- showversion  print product version and  continue
    
- jre - restrict - search  |   - jre - no - restrict - search
                  include
/ exclude user  private  JREs  in  the version search
    
-?   - help      print  this  help message
    
- X            print help on non - standard options
    
- ea[: < packagename > ... | : < classname > ]
    
- enableassertions[: < packagename > ... | : < classname > ]
                  enable assertions
    
- da[: < packagename > ... | : < classname > ]
    
- disableassertions[: < packagename > ... | : < classname > ]
                  disable assertions
    
- esa  |   - enablesystemassertions
                  enable system assertions
    
- dsa  |   - disablesystemassertions
                  disable system assertions
    
- agentlib: < libname > [ =< options > ]
                  load native agent library 
< libname > , e.g.  - agentlib:hprof
                    see also, 
- agentlib:jdwp = help and  - agentlib:hprof = help
    
- agentpath: < pathname > [ =< options > ]
                  load native agent library by full pathname
    
- javaagent: < jarpath > [ =< options > ]
                  load Java programming language agent, see java.lang.instrument
出现这些字样,表明jre安装成功了;
接着,使用alternatives工具增加这个版本;
[root@BlueSky software]# alternatives  -- install  / usr / bin / java java  / usr / java / jre1. 5 .0_09 / bin / java  300
配置:
[root@BlueSky software]# alternatives  -- config java

共有 
2  个程序提供“java”。

  选择    命令
-----------------------------------------------
*    1             / usr / lib / jvm / jre - 1.4 . 2 - gcj / bin / java
   
2             / usr / java / jre1. 5 .0_09 / bin / java

按 Enter 来保存当前选择[
+ ],或键入选择号码: 2
[root@BlueSky software]# java
Usage: java [
- options]  class  [args...]
           (to execute a 
class )
   or  java [
- options]  - jar jarfile [args...]
           (to execute a jar file)

where  options include:
    
- d32          use a  32 - bit data model  if  available

    
- d64          use a  64 - bit data model  if  available
    
- client       to select the  " client "  VM
    
- server       to select the  " server "  VM
    
- hotspot       is  a synonym  for  the  " client "  VM  [deprecated]
                  The 
default  VM  is  client.
                  
    
- cp  < class  search path of directories and zip / jar files >
    
- classpath  < class  search path of directories and zip / jar files >
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search 
for   class  files.
    
- D < name >=< value >
                  
set  a system property
    
- verbose[: class | gc | jni]
                  enable verbose output
    
- version      print product version and exit
    
- version: < value >
                  require the specified version to run
    
- showversion  print product version and  continue
    
- jre - restrict - search  |   - jre - no - restrict - search
                  include
/ exclude user  private  JREs  in  the version search
    
-?   - help      print  this  help message
    
- X            print help on non - standard options
    
- ea[: < packagename > ... | : < classname > ]
    
- enableassertions[: < packagename > ... | : < classname > ]
                  enable assertions
    
- da[: < packagename > ... | : < classname > ]
    
- disableassertions[: < packagename > ... | : < classname > ]
                  disable assertions
    
- esa  |   - enablesystemassertions
                  enable system assertions
    
- dsa  |   - disablesystemassertions
                  disable system assertions
    
- agentlib: < libname > [ =< options > ]
                  load native agent library 
< libname > , e.g.  - agentlib:hprof
                    see also, 
- agentlib:jdwp = help and  - agentlib:hprof = help
    
- agentpath: < pathname > [ =< options > ]
                  load native agent library by full pathname
    
- javaagent: < jarpath > [ =< options > ]
                  load Java programming language agent, see java.lang.instrument
如此,成功;
查看效果:
[root@BlueSky software]# alternatives  -- display java
java 
-  状态是手工。
 链接目前指向 
/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值