Linux에서 JDK 설치

Posted 2008. 10. 24. 04:41


출처 : http://blog.naver.com/mook0324?Redirect=Log&logNo=130005501334

 

리눅스에서 jdk(java development kit) 을 설치해 보겠습니다.

설치 목적은 sunone web server 를 깔기 위해서 였습니다.(sunone web server 설치는 필자의 블로그에서 sunone 으로 검색하시면 나옴)

환경은 redhat9 이며 fedora 에서도 무리없이 깔리며 Enterprise AS 4 에서도 깔립니다(다 깔아봤음)

 

1. jdk를 다운 받습니다.

 http://java.sun.com/ > download > j2se > JDK 5.0 updates7 > Download jdk 5.0 update 7 >

로 가면 Linux Platform - J2SE(TM) Development Kit 5.0 Update 7 에서

Linux RPM in self-extracting file 와 Linux self-extracting file  파일이 있습니다.

 

2. RPM 파일로 깔기

[root@angka test]# ls
j2re-1_4_2_12-linux-i586.bin  jdk-1_5_0_07-linux-i586-rpm.bin
[root@angka test]# sh j
j2re-1_4_2_12-linux-i586.bin     jdk-1_5_0_07-linux-i586-rpm.bin 
[root@angka test]# sh jdk-1_5_0_07-linux-i586-rpm.bin

( '') binary 파일을 실행시켜 주면 바로 rpm으로 설치 해주며 rpm 파일도 만들어 줍니다.


Sun Microsystems, Inc. Binary Code License Agreement

for the JAVA 2 PLATFORM STANDARD EDITION DEVELOPMENT
KIT 5.0

SUN MICROSYSTEMS, INC.  ("SUN") IS WILLING TO LICENSE
THE SOFTWARE IDENTIFIED BELOW TO YOU ONLY UPON THE
CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN
 

중략 ....

THIRDPARTYLICENSEREADME.txt file, the disclaimer of
warranty and limitation of liability provisions in
paragraphs 5 and 6 of the Binary Code License Agreement
shall apply to all Software in this distribution.

H.  Termination for Infringement.  Either party may
terminate this Agreement immediately should any
Software become, or in either party's opinion be likely
to become, the subject of a claim of infringement of
any intellectual property right.

For inquiries please contact:  Sun Microsystems, Inc.,
4150 Network Circle, Santa Clara, California 95054,
U.S.A.  (LFI#143333/Form ID#011801)

Do you agree to the above license terms? [yes or no]
  yes                                                    <--- 라이센스 정책에 yes 해줍니다.

Unpacking...
Checksumming...
0
0
Extracting...
UnZipSFX 5.42 of 14 January 2001, by Info-ZIP (Zip-Bugs@lists.wku.edu).
  inflating: jdk-1_5_0_07-linux-i586.rpm 
준비 중...                  ########################################### [100%]
   1:jdk                    ########################################### [100%]
 
Done.

[root@angka test]# ls
j2re-1_4_2_12-linux-i586.bin  jdk-1_5_0_07-linux-i586-rpm.bin  jdk-1_5_0_07-linux-i586.rpm

3. 깔린곳 보기

 

[root@angka jdk1.5.0_07]# pwd
/usr/java/jdk1.5.0_07
[root@angka jdk1.5.0_07]# ls
COPYRIGHT  README.html                  bin   include  lib  sample
LICENSE    THIRDPARTYLICENSEREADME.txt  demo  jre      man  src.zip
[root@angka jdk1.5.0_07]#

 

 

4. /etc/profile 이나 /.profile 혹은 /.bash_profile 중 아무곳이나 jdk에 path를 잡아줍니다.

 

[root@angka java]# vi /etc/profile

##### for jdk setting #####
export JAVA_HOME=/usr/java/jdk1.5.0_07

export PATH=$PATH:/usr/java/jdk1.5.0_07/bin   <--- 이 부분을 붙여 주시고
"/etc/profile" 54L, 945C 저장 했습니다                                                
[root@angka java]# . /etc/profile                         <-- 파일을 적용시킵니다.
[root@angka java]#

 

5. 잘 깔렸나 확인해보기

-  jdk 가 RPM으로 잘 깔렸나 확인해봅니다.

[root@angka java]# rpm -qa | grep jdk
jdk-1.5.0_07-fcs
[root@angka java]#

 

-  jdk 의 version을 확인해봅니다.

[root@angka java]# java -version
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
[root@angka java]#

 

 

6. 자 그럼 이제 binary 파일로 깔아 보겠습니다.

 

-1.5 버젼을 깔아 봤으니 binary 파일은 1.4.2 버젼으로 깔아 보겠습니다.

 

- 일단 rpm 으로 깐 jdk를 지웁니다.

[root@angka java]# rpm -e jdk-1.5.0_07-fcs

 

- /test 로 받았던 파일을 /usr/local 로 옮깁니다. 왜냐면 binary 파일은 실행시킨 그 디렉토리 밑에 설치가 되기 때문이며 보통 리눅스 소프트웨어는 /usr/local 밑에 깔기때문이져.

 

[root@angka local]# mv j2re-1_4_2_12-linux-i586.bin /test
[root@angka local]# cd /test
[root@angka test]# ls
j2re-1_4_2_12-linux-i586.bin  jdk-1_5_0_07-linux-i586-rpm.bin
[root@angka test]# mv j2re-1_4_2_12-linux-i586.bin /usr/local
[root@angka test]# cd /usr/local
[root@angka local]# ls
bin  etc  games  include  j2re-1_4_2_12-linux-i586.bin  lib  libexec  man  sbin  share  src
[root@angka local]#

 

- 파일을 실행 시킵니다.

 

[root@angka local]# sh j2re-1_4_2_12-linux-i586.bin

 

          Sun Microsystems, Inc.
          Binary Code License Agreement
                  for the
JAVATM 2 RUNTIME ENVIRONMENT (J2RE), STANDARD EDITION,
              VERSION 1.4.2_X

SUN MICROSYSTEMS, INC. ("SUN") IS WILLING TO LICENSE THE
SOFTWARE IDENTIFIED BELOW TO YOU ONLY UPON THE CONDITION
THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS BINARY
CODE LICENSE AGREEMENT AND SUPPLEMENTAL LICENSE TERMS
(COLLECTIVELY "AGREEMENT").  PLEASE READ THE AGREEMENT
CAREFULLY.  BY DOWNLOADING OR INSTALLING THIS SOFTWARE, YOU
ACCEPT THE TERMS OF THE AGREEMENT. INDICATE ACCEPTANCE BY
SELECTING THE "ACCEPT" BUTTON AT THE BOTTOM OF THE
AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY ALL THE
TERMS, SELECT THE "DECLINE" BUTTON AT THE BOTTOM OF THE
AGREEMENT AND THE DOWNLOAD OR INSTALL PROCESS WILL NOT
CONTINUE.

 

중략....

 

F.Third Party Code. Additional copyright notices and
license terms applicable to portions of the Software are
set forth in the THIRDPARTYLICENSEREADME.txt file. In
addition to any terms and conditions of any third party
opensource/freeware license identified in the
THIRDPARTYLICENSEREADME.txt file, the disclaimer of
warranty and limitation of liability provisions in
paragraphs 5 and 6 of the Binary Code License Agreement
shall apply to all Software in this distribution.

For inquiries please contact: Sun Microsystems, Inc., 4150
Network Circle, Santa Clara, California 95054, U.S.A.
(LFI#129530/Form ID#011801)

Do you agree to the above license terms? [yes or no]
 yes                                     <--- 역시 라이센스 정책에 yes 해줍니다.

 

... 중략...

 extracting: j2re1.4.2_12/javaws/sunlogo64x30.gif 
Creating j2re1.4.2_12/lib/rt.jar
Creating j2re1.4.2_12/lib/jsse.jar
Creating j2re1.4.2_12/lib/charsets.jar
Creating j2re1.4.2_12/lib/ext/localedata.jar
Creating j2re1.4.2_12/lib/plugin.jar
Creating j2re1.4.2_12/javaws/javaws.jar
Done.            <-- 설치가 끝났내요

 

- /usr/local 디렉토리에 j2re1.4.2_12 디렉토리가 만들어 진것이 보일겁니다. 이걸로 jdk를 binary 로 까는것은 끝입니다. 넘 간단한가..^^"

[root@angka local]# ls
bin  games    j2re-1_4_2_12-linux-i586.bin  lib      man   share
etc  include  j2re1.4.2_12                  libexec  sbin  src
[root@angka local]#

 

- 마찬가지로 /etc/profile , /.profile , /.bash_profile 중 하나에 java  path를 설정해 줍니다.

 

[root@angka local]# vi /etc/profile

##### for jdk setting #####
export JAVA_HOME=/usr/local/j2re1.4.2_12
export PATH=$PATH:/usr/local/j2re1.4.2_12/bin

"/etc/profile" 54L, 955C 저장 했습니다                                               
[root@angka local]# . /etc/profile  <-- 역시 설정 변경한것을 읽혀줍니다.

 

주의 하실점은 rpm으로 깔았을때 기본 디렉토리는 /usr/local 이 아니라 /usr/java 로 된다는 것입니다. 여러분들이 저에게 문의하시는데 /usr/java 밑으로 들어갑니다.

 

끝..