- 리눅스 JDK 설치
개요
- 리눅스에서도[1] JDK와 JRE는 별도의 패키지이다.
- java-버전-openjdk 패키지가 JRE, java-버전-openjdk-devel 패키지가 JDK라고 생각하면 된다.
- JDK가 JRE에 의존성이 있다.[2]
- yum으로 JDK를 설치하려고 하면 JRE를 먼저 설치한다.
설치 확인
- 리눅스 JDK 설치 확인 문서를 참고하십시오.
설치가능 확인
[root@zetawiki ~]# yum list java*jdk-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
java-1.6.0-openjdk-devel.x86_64 1:1.6.0.0-1.30.1.11.5.el5 Daum
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.9-2.3.3.el5.1 Daum
- → 1.6.0과 1.7.0 버전이 설치 가능하다.
- → 여기서는 1.7.0 버전을 설치한다.
[root@zetawiki ~]# yum list java*jdk-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Available Packages java-1.6.0-openjdk-devel.x86_64 1:1.6.0.0-1.30.1.11.5.el5 Daum java-1.7.0-openjdk-devel.x86_64 1:1.7.0.9-2.3.3.el5.1 Daum
설치
[root@zetawiki ~]# 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.4.1.el6_3 updates 9.4 M
Installing for dependencies:
giflib x86_64 4.1.6-3.1.el6 base 37 k
java-1.7.0-openjdk x86_64 1:1.7.0.9-2.3.4.1.el6_3 updates 26 M
jline noarch 0.9.94-0.8.el6 base 86 k
jpackage-utils noarch 1.7.5-3.12.el6 base 59 k
rhino noarch 1.7-0.7.r2.2.el6 base 778 k
tzdata-java noarch 2012j-1.el6 updates 155 k
Transaction Summary
==================================================================================================================
Install 7 Package(s)
Total download size: 36 M
Installed size: 126 M
Is this ok [y/N]: y
... (생략)
Installed:
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.9-2.3.4.1.el6_3
Dependency Installed:
giflib.x86_64 0:4.1.6-3.1.el6 java-1.7.0-openjdk.x86_64 1:1.7.0.9-2.3.4.1.el6_3
jline.noarch 0:0.9.94-0.8.el6 jpackage-utils.noarch 0:1.7.5-3.12.el6
rhino.noarch 0:1.7-0.7.r2.2.el6 tzdata-java.noarch 0:2012j-1.el6
Complete!
[root@zetawiki ~]# 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.4.1.el6_3 updates 9.4 M Installing for dependencies: giflib x86_64 4.1.6-3.1.el6 base 37 k java-1.7.0-openjdk x86_64 1:1.7.0.9-2.3.4.1.el6_3 updates 26 M jline noarch 0.9.94-0.8.el6 base 86 k jpackage-utils noarch 1.7.5-3.12.el6 base 59 k rhino noarch 1.7-0.7.r2.2.el6 base 778 k tzdata-java noarch 2012j-1.el6 updates 155 k Transaction Summary ================================================================================================================== Install 7 Package(s) Total download size: 36 M Installed size: 126 M Is this ok [y/N]: y
... (생략) Installed: java-1.7.0-openjdk-devel.x86_64 1:1.7.0.9-2.3.4.1.el6_3 Dependency Installed: giflib.x86_64 0:4.1.6-3.1.el6 java-1.7.0-openjdk.x86_64 1:1.7.0.9-2.3.4.1.el6_3 jline.noarch 0:0.9.94-0.8.el6 jpackage-utils.noarch 0:1.7.5-3.12.el6 rhino.noarch 0:1.7-0.7.r2.2.el6 tzdata-java.noarch 0:2012j-1.el6 Complete!
설치 확인
[root@zetawiki ~]# rpm -qa java*jdk-devel
java-1.7.0-openjdk-devel-1.7.0.9-2.3.4.1.el6_3.x86_64
[root@zetawiki ~]# javac -version
javac 1.7.0_09
[root@zetawiki ~]# rpm -qa java*jdk-devel java-1.7.0-openjdk-devel-1.7.0.9-2.3.4.1.el6_3.x86_64
[root@zetawiki ~]# javac -version
javac 1.7.0_09
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
rm -f HelloWorld.java HelloWorld.class
- 예시
[root@zetawiki ~]# echo "public class HelloWorld {" > HelloWorld.java
[root@zetawiki ~]# echo " public static void main(String[] args) {" >> HelloWorld.java
[root@zetawiki ~]# echo " System.out.println(\"Hello, World\");" >> HelloWorld.java
[root@zetawiki ~]# echo " }" >> HelloWorld.java
[root@zetawiki ~]# echo "}" >> HelloWorld.java
[root@zetawiki ~]# javac HelloWorld.java
[root@zetawiki ~]# java HelloWorld
Hello, World
[root@zetawiki ~]# rm -f HelloWorld.java HelloWorld.class
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 rm -f HelloWorld.java HelloWorld.class
[root@zetawiki ~]# echo "public class HelloWorld {" > HelloWorld.java [root@zetawiki ~]# echo " public static void main(String[] args) {" >> HelloWorld.java [root@zetawiki ~]# echo " System.out.println(\"Hello, World\");" >> HelloWorld.java [root@zetawiki ~]# echo " }" >> HelloWorld.java [root@zetawiki ~]# echo "}" >> HelloWorld.java [root@zetawiki ~]# javac HelloWorld.java [root@zetawiki ~]# java HelloWorld Hello, World [root@zetawiki ~]# rm -f HelloWorld.java HelloWorld.class
댓글 없음:
댓글 쓰기