linux系统alternatives使用(java,javac,jar)

[host@localhost ~]$ alternatives --help
alternatives version 1.3.44 - Copyright (C) 2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.

usage: 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>

common options: --verbose --test --help --usage --version
                --altdir <directory> --admindir <directory>

 

[例1]

alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.5.0_21/jre/bin/java 3

 

[host@localhost android_eclair]$ update-alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 3           /usr/lib/jvm/jdk1.5.0_21/jre/bin/java

 

[例2]

alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.5.0_21/bin/javac 2

 

[host@localhost android_eclair]$ update-alternatives --config javac

There are 2 programs which provide 'javac'.

  Selection    Command
-----------------------------------------------
*  1           /usr/lib/jvm/java-1.6.0-openjdk/bin/javac
 + 2           /usr/lib/jvm/jdk1.5.0_21/bin/javac

 

[host@localhost jvm]$ ls /usr/bin/j* -l
-rwxr-xr-x 1 root root 21068 2009-11-05 04:54 /usr/bin/jackd
-rwxr-xr-x 1 root root  7420 2009-11-05 04:54 /usr/bin/jack_freewheel
-rwxr-xr-x 1 root root  9408 2009-11-05 04:54 /usr/bin/jack_load
-rwxr-xr-x 1 root root  7508 2009-11-05 04:54 /usr/bin/jack_unload
lrwxrwxrwx 1 root root    21 2010-04-28 07:41 /usr/bin/jar -> /etc/alternatives/jar
lrwxrwxrwx 1 root root    27 2010-04-28 07:41 /usr/bin/jarsigner -> /etc/alternatives/jarsigner
lrwxrwxrwx 1 root root    22 2010-02-08 16:59 /usr/bin/java -> /etc/alternatives/java
lrwxrwxrwx 1 root root    23 2010-04-28 07:41 /usr/bin/javac -> /etc/alternatives/javac
lrwxrwxrwx 1 root root    25 2010-04-28 07:41 /usr/bin/javadoc -> /etc/alternatives/javadoc
lrwxrwxrwx 1 root root    23 2010-04-28 07:41 /usr/bin/javah -> /etc/alternatives/javah
lrwxrwxrwx 1 root root    23 2010-04-28 07:41 /usr/bin/javap -> /etc/alternatives/javap

lrwxrwxrwx 1 root root    26 2010-04-28 07:41 /usr/bin/jconsole -> /etc/alternatives/jconsole
lrwxrwxrwx 1 root root    21 2010-04-28 07:41 /usr/bin/jdb -> /etc/alternatives/jdb
-rwxr-xr-x 1 root root   541 2009-07-26 21:02 /usr/bin/jh2indexer
-rwxr-xr-x 1 root root   538 2009-07-26 21:02 /usr/bin/jh2search
lrwxrwxrwx 1 root root    22 2010-04-28 07:41 /usr/bin/jhat -> /etc/alternatives/jhat
lrwxrwxrwx 1 root root    23 2010-04-28 07:41 /usr/bin/jinfo -> /etc/alternatives/jinfo
lrwxrwxrwx 1 root root    22 2010-04-28 07:41 /usr/bin/jmap -> /etc/alternatives/jmap
-rwxr-xr-x 1 root root 40644 2009-09-22 22:01 /usr/bin/join
-rwxr-xr-x 1 root root 23540 2009-07-27 02:21 /usr/bin/jpegicc
-rwxr-xr-x 1 root root 23288 2009-07-27 04:51 /usr/bin/jpegtran
lrwxrwxrwx 1 root root    21 2010-04-28 07:41 /usr/bin/jps -> /etc/alternatives/jps
lrwxrwxrwx 1 root root    28 2010-04-28 07:41 /usr/bin/jrunscript -> /etc/alternatives/jrunscript
lrwxrwxrwx 1 root root    27 2010-04-28 07:41 /usr/bin/jsadebugd -> /etc/alternatives/jsadebugd
-rwxr-xr-x 1 root root  8168 2009-08-10 17:16 /usr/bin/jsattach
-rwxr-xr-x 1 root root 15820 2009-08-10 17:16 /usr/bin/jscal
lrwxrwxrwx 1 root root    24 2010-04-28 07:41 /usr/bin/jstack -> /etc/alternatives/jstack
lrwxrwxrwx 1 root root    23 2010-04-28 07:41 /usr/bin/jstat -> /etc/alternatives/jstat
lrwxrwxrwx 1 root root    24 2010-04-28 07:41 /usr/bin/jstatd -> /etc/alternatives/jstatd
-rwxr-xr-x 1 root root  8492 2009-08-10 17:16 /usr/bin/jstest
-rwxr-xr-x 1 root root  6688 2009-10-28 04:23 /usr/bin/jv-convert
lrwxrwxrwx 1 root root    27 2010-04-28 07:41 /usr/bin/jvisualvm -> /etc/alternatives/jvisualvm
-rwxr-xr-x 1 root root  1757 2006-09-20 03:55 /usr/bin/jvmjar
-rwxr-xr-x 1 root root 64388 2009-09-03 17:16 /usr/bin/jwhois

 

[host@localhost jvm]$ ls -l /etc/alternatives/java*
lrwxrwxrwx 1 root root 37 2010-02-08 16:59 /etc/alternatives/java -> /usr/lib/jvm/jdk1.5.0_21/jre/bin/java
lrwxrwxrwx 1 root root 41 2010-04-28 07:41 /etc/alternatives/javac -> /usr/lib/jvm/java-1.6.0-openjdk/bin/javac
lrwxrwxrwx 1 root root 49 2010-04-28 07:41 /etc/alternatives/javac.1.gz -> /usr/share/man/man1/javac-java-1.6.0-openjdk.1.gz
lrwxrwxrwx 1 root root 43 2010-04-28 07:41 /etc/alternatives/javadoc -> /usr/lib/jvm/java-1.6.0-openjdk/bin/javadoc
lrwxrwxrwx 1 root root 51 2010-04-28 07:41 /etc/alternatives/javadoc.1.gz -> /usr/share/man/man1/javadoc-java-1.6.0-openjdk.1.gz
lrwxrwxrwx 1 root root 41 2010-04-28 07:41 /etc/alternatives/javah -> /usr/lib/jvm/java-1.6.0-openjdk/bin/javah
lrwxrwxrwx 1 root root 49 2010-04-28 07:41 /etc/alternatives/javah.1.gz -> /usr/share/man/man1/javah-java-1.6.0-openjdk.1.gz
lrwxrwxrwx 1 root root 41 2010-04-28 07:41 /etc/alternatives/javap -> /usr/lib/jvm/java-1.6.0-openjdk/bin/javap
lrwxrwxrwx 1 root root 49 2010-04-28 07:41 /etc/alternatives/javap.1.gz -> /usr/share/man/man1/javap-java-1.6.0-openjdk.1.gz
lrwxrwxrwx 1 root root 31 2010-04-28 07:41 /etc/alternatives/java_sdk -> /usr/lib/jvm/java-1.6.0-openjdk
lrwxrwxrwx 1 root root 31 2010-04-28 07:41 /etc/alternatives/java_sdk_1.6.0 -> /usr/lib/jvm/java-1.6.0-openjdk
lrwxrwxrwx 1 root root 39 2010-04-28 07:41 /etc/alternatives/java_sdk_1.6.0_exports -> /usr/lib/jvm-exports/java-1.6.0-openjdk
lrwxrwxrwx 1 root root 39 2010-04-28 07:41 /etc/alternatives/java_sdk_exports -> /usr/lib/jvm-exports/java-1.6.0-openjdk
lrwxrwxrwx 1 root root 31 2010-04-28 07:41 /etc/alternatives/java_sdk_openjdk -> /usr/lib/jvm/java-1.6.0-openjdk
lrwxrwxrwx 1 root root 39 2010-04-28 07:41 /etc/alternatives/java_sdk_openjdk_exports -> /usr/lib/jvm-exports/java-1.6.0-openjdk

[host@localhost jvm]$ ls -l /etc/alternatives/jre*
lrwxrwxrwx 1 root root 26 2010-04-28 05:24 /etc/alternatives/jre_1.5.0 -> /usr/lib/jvm/jre-1.5.0-gcj
lrwxrwxrwx 1 root root 34 2010-04-28 05:24 /etc/alternatives/jre_1.5.0_exports -> /usr/lib/jvm-exports/jre-1.5.0-gcj
lrwxrwxrwx 1 root root 30 2010-04-28 07:41 /etc/alternatives/jre_1.6.0 -> /usr/lib/jvm/jre-1.6.0-openjdk
lrwxrwxrwx 1 root root 38 2010-04-28 07:41 /etc/alternatives/jre_1.6.0_exports -> /usr/lib/jvm-exports/jre-1.6.0-openjdk
lrwxrwxrwx 1 root root 26 2010-04-28 05:24 /etc/alternatives/jre_gcj -> /usr/lib/jvm/jre-1.5.0-gcj
lrwxrwxrwx 1 root root 34 2010-04-28 05:24 /etc/alternatives/jre_gcj_exports -> /usr/lib/jvm-exports/jre-1.5.0-gcj
lrwxrwxrwx 1 root root 30 2010-04-28 07:41 /etc/alternatives/jre_openjdk -> /usr/lib/jvm/jre-1.6.0-openjdk
lrwxrwxrwx 1 root root 38 2010-04-28 07:41 /etc/alternatives/jre_openjdk_exports -> /usr/lib/jvm-exports/jre-1.6.0-openjdk

 

执行例子1,2后:
[host@localhost jvm]$ ls -l /etc/alternatives/java*
lrwxrwxrwx 1 root root 37 2010-02-08 16:59 /etc/alternatives/java -> /usr/lib/jvm/jdk1.5.0_21/jre/bin/java
lrwxrwxrwx 1 root root 34 2010-02-08 17:25 /etc/alternatives/javac -> /usr/lib/jvm/jdk1.5.0_21/bin/javac
lrwxrwxrwx 1 root root 31 2010-04-28 07:41 /etc/alternatives/java_sdk_1.6.0 -> /usr/lib/jvm/java-1.6.0-openjdk
lrwxrwxrwx 1 root root 39 2010-04-28 07:41 /etc/alternatives/java_sdk_1.6.0_exports -> /usr/lib/jvm-exports/java-1.6.0-openjdk
lrwxrwxrwx 1 root root 31 2010-04-28 07:41 /etc/alternatives/java_sdk_openjdk -> /usr/lib/jvm/java-1.6.0-openjdk
lrwxrwxrwx 1 root root 39 2010-04-28 07:41 /etc/alternatives/java_sdk_openjdk_exports -> /usr/lib/jvm-exports/java-1.6.0-openjdk


[host@localhost jvm]$ ls -l /etc/alternatives/jre*
lrwxrwxrwx 1 root root 26 2010-04-28 05:24 /etc/alternatives/jre_1.5.0 -> /usr/lib/jvm/jre-1.5.0-gcj
lrwxrwxrwx 1 root root 34 2010-04-28 05:24 /etc/alternatives/jre_1.5.0_exports -> /usr/lib/jvm-exports/jre-1.5.0-gcj
lrwxrwxrwx 1 root root 30 2010-04-28 07:41 /etc/alternatives/jre_1.6.0 -> /usr/lib/jvm/jre-1.6.0-openjdk
lrwxrwxrwx 1 root root 38 2010-04-28 07:41 /etc/alternatives/jre_1.6.0_exports -> /usr/lib/jvm-exports/jre-1.6.0-openjdk
lrwxrwxrwx 1 root root 26 2010-04-28 05:24 /etc/alternatives/jre_gcj -> /usr/lib/jvm/jre-1.5.0-gcj
lrwxrwxrwx 1 root root 34 2010-04-28 05:24 /etc/alternatives/jre_gcj_exports -> /usr/lib/jvm-exports/jre-1.5.0-gcj
lrwxrwxrwx 1 root root 30 2010-04-28 07:41 /etc/alternatives/jre_openjdk -> /usr/lib/jvm/jre-1.6.0-openjdk
lrwxrwxrwx 1 root root 38 2010-04-28 07:41 /etc/alternatives/jre_openjdk_exports -> /usr/lib/jvm-exports/jre-1.6.0-openjdk

你可能感兴趣的:(linux系统alternatives使用(java,javac,jar))