alternative 명령어로 default java 버전 변경

대부분의 리눅스 배포본에는 Java JDK 가 버전별로 여러개를 설치할 수 있도록 패키지가 구성되어있습니다.

여러버전의 JDK를 설치하였을때 기본으로 실행되는 Java 버전을 변경하는 방법은 alternative 명령어를 이용하는것입니다.

alternatives 라는 명령어를 그냥 실행해 보면 아래와 같이 Help를 확인할 수 있다.

[root@rhel6 ~]# alternatives --help
alternatives version 1.3.49.3 - 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>

사실 이 명령어로 여러가지 환경을 변경할 수 있지만 여기서는 Java 버전을 변경해보도록 합시다.

[root@rhel6 ~]# alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   3           /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64/jre/bin/java

Enter to keep the current selection[+], or type selection number:
로그인하면 댓글을 남길 수 있습니다.
  • alternative_명령어로_default_java_버전_변경.txt
  • 마지막으로 수정됨: 2015/06/18 15:49
  • 저자 127.0.0.1