[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
-
状态是手工。
链接目前指向
/
usr
/
java
/
jre1.
5
.0_09
/
bin
/
java
/
usr
/
lib
/
jvm
/
jre
-
1.4
.
2
-
gcj
/
bin
/
java
-
优先度
1420
从 keytool:
/
usr
/
lib
/
jvm
/
jre
-
1.4
.
2
-
gcj
/
bin
/
keytool
从 rmiregistry:
/
usr
/
lib
/
jvm
/
jre
-
1.4
.
2
-
gcj
/
bin
/
rmiregistry
从 jre_exports:
/
usr
/
lib
/
jvm
-
exports
/
jre
-
1.4
.
2
-
gcj
从 jre:
/
usr
/
lib
/
jvm
/
jre
-
1.4
.
2
-
gcj
/
usr
/
java
/
jre1.
5
.0_09
/
bin
/
java
-
优先度
300
从 keytool:(
null
)
从 rmiregistry:(
null
)
从 jre_exports:(
null
)
从 jre:(
null
)
当前“最佳”版本是
/
usr
/
lib
/
jvm
/
jre
-
1.4
.
2
-
gcj
/
bin
/
java。
结论,alternaties这个工具还是不错的。。。