CentOS JDK 설치

Jmnote (토론 | 기여)님의 2013년 1월 26일 (토) 02:29 판 (→‎JDK 설치)
리눅스 JDK 설치

1 개요

  • yum으로 설치함.
  • oracle.com에서 JDK를 다운로드 받으면 거기에 JRE도 포함되어 있고 JDK 설치시 JRE도 설치하겠냐고 물어본다. 하지만 yum 패키지는 따로 되어 있다.

2 설치 확인

3 JRE 설치

명령어
yum install java -y
예시
[root@jmnote ~]# yum install java -y
Loaded plugins: langpacks, presto, refresh-packagekit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package java-1.6.0-openjdk.i686 1:1.6.0.0-59.1.10.3.fc16 will be updated
---> Package java-1.6.0-openjdk.i686 1:1.6.0.0-61.1.10.4.fc16 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================
 Package                   Arch        Version                            Repository      Size
===============================================================================================
Updating:
 java-1.6.0-openjdk        i686        1:1.6.0.0-61.1.10.4.fc16           updates         26 M

Transaction Summary
===============================================================================================
Upgrade       1 Package

Total download size: 26 M
Downloading Packages:
Setting up and reading Presto delta metadata
updates/prestodelta                                                     | 635 kB     00:00     
Processing delta metadata
Download delta size: 1.3 M
java-1.6.0-openjdk-1.6.0.0-59.1.10.3.fc16_1.6.0.0-61.1.10.4.fc16.i686.d | 1.3 MB     00:00     
Finishing rebuild of rpms, from deltarpms
<locally rebuilding deltarpms>                                          |  26 MB     00:18     
Presto reduced the update size by 96% (from 26 M to 1.3 M).
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : 1:java-1.6.0-openjdk-1.6.0.0-61.1.10.4.fc16.i686                            1/2 
  Cleanup    : 1:java-1.6.0-openjdk-1.6.0.0-59.1.10.3.fc16.i686                            2/2 

Updated:
  java-1.6.0-openjdk.i686 1:1.6.0.0-61.1.10.4.fc16                                             

Complete!
버전 확인
[root@jmnote ~]# java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.4) (fedora-61.1.10.4.fc16-i386)
OpenJDK Client VM (build 20.0-b11, mixed mode)

4 JDK+JRE 설치

명령어
yum info java*jdk java*jdk*devel | egrep "(Name|Repo)"
yum install java-버전-openjdk -y
설치가능패키지 확인
[root@jmnote ~]# yum info java*jdk-devel | egrep "(Name|Repo)"
Name       : java-1.6.0-openjdk-devel
Repo       : Daum
Name       : java-1.7.0-openjdk-devel
Repo       : Daum
→ 1.6.0과 1.7.0 버전이 설치 가능하다.
→ 여기서는 1.7.0 버전을 설치하겠다...
설치
[root@jmnote ~]# yum install java-1.7.0-openjdk-devel
... (생략)
================================================================================
 Package                     Arch      Version                    Repository
                                                                           Size
================================================================================
Installing:
 java-1.7.0-openjdk-devel    x86_64    1:1.7.0.9-2.3.3.el5.1      Daum     12 M
Installing for dependencies:
 java-1.7.0-openjdk          x86_64    1:1.7.0.9-2.3.3.el5.1      Daum     39 M
 jline                       noarch    0.9.94-0.9.el5_6           Daum     85 k
 rhino                       noarch    1.7-0.7.r2.3.el5_6         Daum    787 k
 tzdata-java                 x86_64    2012i-2.el5                Daum    183 k

Transaction Summary
================================================================================
Install       5 Package(s)
Upgrade       0 Package(s)

Total download size: 52 M
Is this ok [y/N]:
y Enter
... (생략)
Installed:
  java-1.7.0-openjdk-devel.x86_64 1:1.7.0.9-2.3.3.el5.1                         

Dependency Installed:
  java-1.7.0-openjdk.x86_64 1:1.7.0.9-2.3.3.el5.1                               
  jline.noarch 0:0.9.94-0.9.el5_6                                               
  rhino.noarch 0:1.7-0.7.r2.3.el5_6                                             
  tzdata-java.x86_64 0:2012i-2.el5                                              

Complete!
버전 확인
[root@jmnote ~]# rpm -qa java*devel
java-1.7.0-openjdk-devel-1.7.0.9-2.3.3.el5.1
[root@jmnote ~]# javac -version
javac 1.7.0_09

5 설치 위치

6 Hello world 테스트

명령어
echo "public class HelloWorld {" > HelloWorld.java
echo "  public static void main(String[] args) {" >> HelloWorld.java
echo "    System.out.println(\"Hello, World\");" >> HelloWorld.java
echo "  }" >> HelloWorld.java
echo "}" >> HelloWorld.java
javac HelloWorld.java
java HelloWorld
예시
[root@jmnote ~]# echo "public class HelloWorld {" > HelloWorld.java
[root@jmnote ~]# echo "  public static void main(String[] args) {" >> HelloWorld.java
[root@jmnote ~]# echo "    System.out.println(\"Hello, World\");" >> HelloWorld.java
[root@jmnote ~]# echo "  }" >> HelloWorld.java
[root@jmnote ~]# echo "}" >> HelloWorld.java
[root@jmnote ~]# javac HelloWorld.java
[root@jmnote ~]# java HelloWorld
Hello, World

7 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}