리눅스에서 기본적으로 java는 설치되어 있는데요.
javac는 설치되어 있지 않습니다.^^;;
java 공부를 위해 JDK 먼저 설치하겠습니다.
윈도우에서는 jdk 버전이지만 리눅스에서는 jdk-devel 버전을 설치합니다.
■ 설치가능한 JDK 리스트 확인하기
yum 리스트에서 devel 버전이 JDK입니다.
요즘 많이 사용되고 있는 1.8 버전을 설치할게요.
[sidepower@localhost java]$ yum list java*jdk* 설치된 패키지 java-1.8.0-openjdk-headless.x86_64 1:1.8.0.272.b10-1.el8_2 @AppStream 사용 가능한 패키지 java-1.8.0-openjdk.x86_64 1:1.8.0.275.b01-1.el8_3 AppStream java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.275.b01-1.el8_3 AppStream java-1.8.0-openjdk-demo.x86_64 1:1.8.0.275.b01-1.el8_3 AppStream java-1.8.0-openjdk-devel.x86_64 1:1.8.0.275.b01-1.el8_3 AppStream java-1.8.0-openjdk-headless.x86_64 1:1.8.0.275.b01-1.el8_3 AppStream java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.275.b01-1.el8_3 AppStream java-1.8.0-openjdk-javadoc-zip.noarch 1:1.8.0.275.b01-1.el8_3 AppStream java-1.8.0-openjdk-src.x86_64 1:1.8.0.275.b01-1.el8_3 AppStream java-11-openjdk.x86_64 1:11.0.9.11-3.el8_3 AppStream java-11-openjdk-demo.x86_64 1:11.0.9.11-3.el8_3 AppStream java-11-openjdk-devel.x86_64 1:11.0.9.11-3.el8_3 AppStream java-11-openjdk-headless.x86_64 1:11.0.9.11-3.el8_3 AppStream java-11-openjdk-javadoc.x86_64 1:11.0.9.11-3.el8_3 AppStream java-11-openjdk-javadoc-zip.x86_64 1:11.0.9.11-3.el8_3 AppStream java-11-openjdk-jmods.x86_64 1:11.0.9.11-3.el8_3 AppStream java-11-openjdk-src.x86_64 1:11.0.9.11-3.el8_3 AppStream java-11-openjdk-static-libs.x86_64 1:11.0.9.11-3.el8_3 AppStream java-latest-openjdk.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-demo.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-demo-fastdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-demo-slowdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-devel.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-devel-fastdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-devel-slowdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-fastdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-headless.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-headless-fastdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-headless-slowdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-javadoc.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-javadoc-zip.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-jmods.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-jmods-fastdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-jmods-slowdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-slowdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-src.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-src-fastdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-src-slowdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-static-libs.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-static-libs-fastdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-static-libs-slowdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel #devel 버전만 확인하기 [sidepower@localhost java]$ yum list java*jdk*devel* java-1.8.0-openjdk-devel.x86_64 1:1.8.0.275.b01-1.el8_3 AppStream java-11-openjdk-devel.x86_64 1:11.0.9.11-3.el8_3 AppStream java-latest-openjdk-devel.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-devel-fastdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel java-latest-openjdk-devel-slowdebug.x86_64 1:15.0.1.9-2.rolling.el8 epel |
■ java-1.8.0-openjdk-devel.x86_64 설치하기
[sidepower@localhost java]$ sudo yum install java-1.8.0-openjdk-devel.x86_64 Dependencies resolved. ============================================================================ Package Architecture Version Repository Size ============================================================================ Installing: java-1.8.0-openjdk-devel x86_64 1:1.8.0.275.b01-1.el8_3 AppStream 9.8 M Upgrading: java-1.8.0-openjdk-headless x86_64 1:1.8.0.275.b01-1.el8_3 AppStream 34 M Installing dependencies: java-1.8.0-openjdk x86_64 1:1.8.0.275.b01-1.el8_3 AppStream 330 k ttmkfdir x86_64 3.0.9-54.el8 AppStream 62 k xorg-x11-fonts-Type1 noarch 7.5-19.el8 AppStream 522 k Transaction Summary ============================================================================ 설치 4 Packages 업그레이드 1 Package Total download size: 45 M Is this ok [y/N]: y 패키지 다운로드중: (1/5): ttmkfdir-3.0.9-54.el8.x86_64.rpm 813 kB/s | 62 kB 00:00 (2/5): java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64.rpm 2.5 MB/s | 330 kB 00:00 (3/5): xorg-x11-fonts-Type1-7.5-19.el8.noarch.rpm 2.3 MB/s | 522 kB 00:00 (4/5): java-1.8.0-openjdk-devel-1.8.0.275.b01-1.el8_3.x86_64.rpm 4.1 MB/s | 9.8 MB 00:02 (5/5): java-1.8.0-openjdk-headless-1.8.0.275.b01-1.el8_3.x86_64.rpm 7.1 MB/s | 34 MB 00:04 ------------------------------------------------------------------------------------------------------------------------ 합계 8.5 MB/s | 45 MB 00:05 트랜잭션 점검 실행 중 트랜잭션 검사가 성공했습니다. 트랜잭션 테스트 실행 중 트랜잭션 테스트가 완료되었습니다. 거래 실행 중 스크립틀릿 실행: java-1.8.0-openjdk-headless-1:1.8.0.275.b01-1.el8_3.x86_64 1/1 준비 중입니다 : 1/1 Upgrading : java-1.8.0-openjdk-headless-1:1.8.0.275.b01-1.el8_3.x86_64 1/6 경고: /etc/java/java-1.8.0-openjdk/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/lib/security/java.security(이)가 /etc/java/java-1.8.0-openjdk/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/lib/security/java.security.rpmnew(으)로 생성되었습니다 스크립틀릿 실행: java-1.8.0-openjdk-headless-1:1.8.0.275.b01-1.el8_3.x86_64 1/6 restored /etc/java/java-1.8.0-openjdk/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/lib/security/java.security.rpmnew to /etc/java/java-1.8.0-openjdk/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/lib/security/java.security mv: cannot stat '/etc/java/java-1.8.0-openjdk/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/lib/security/java.security.rpmnew': 그런 파일이나 디렉터리가 없습니다 FAILED to restore /etc/java/java-1.8.0-openjdk/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/lib/security/java.security.rpmnew to /etc/java/java-1.8.0-openjdk/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/lib/security/java.security Installing : ttmkfdir-3.0.9-54.el8.x86_64 2/6 Installing : xorg-x11-fonts-Type1-7.5-19.el8.noarch 3/6 스크립틀릿 실행: xorg-x11-fonts-Type1-7.5-19.el8.noarch 3/6 Installing : java-1.8.0-openjdk-1:1.8.0.275.b01-1.el8_3.x86_64 4/6 스크립틀릿 실행: java-1.8.0-openjdk-1:1.8.0.275.b01-1.el8_3.x86_64 4/6 Installing : java-1.8.0-openjdk-devel-1:1.8.0.275.b01-1.el8_3.x86_64 5/6 스크립틀릿 실행: java-1.8.0-openjdk-devel-1:1.8.0.275.b01-1.el8_3.x86_64 5/6 정리 : java-1.8.0-openjdk-headless-1:1.8.0.272.b10-1.el8_2.x86_64 6/6 스크립틀릿 실행: java-1.8.0-openjdk-headless-1:1.8.0.272.b10-1.el8_2.x86_64 6/6 스크립틀릿 실행: java-1.8.0-openjdk-1:1.8.0.275.b01-1.el8_3.x86_64 6/6 스크립틀릿 실행: java-1.8.0-openjdk-devel-1:1.8.0.275.b01-1.el8_3.x86_64 6/6 스크립틀릿 실행: java-1.8.0-openjdk-headless-1:1.8.0.272.b10-1.el8_2.x86_64 6/6 확인 중 : java-1.8.0-openjdk-1:1.8.0.275.b01-1.el8_3.x86_64 1/6 확인 중 : java-1.8.0-openjdk-devel-1:1.8.0.275.b01-1.el8_3.x86_64 2/6 확인 중 : ttmkfdir-3.0.9-54.el8.x86_64 3/6 확인 중 : xorg-x11-fonts-Type1-7.5-19.el8.noarch 4/6 확인 중 : java-1.8.0-openjdk-headless-1:1.8.0.275.b01-1.el8_3.x86_64 5/6 확인 중 : java-1.8.0-openjdk-headless-1:1.8.0.272.b10-1.el8_2.x86_64 6/6 Installed products updated. 업그레이드 됨: java-1.8.0-openjdk-headless-1:1.8.0.275.b01-1.el8_3.x86_64 설치됨: java-1.8.0-openjdk-1:1.8.0.275.b01-1.el8_3.x86_64 java-1.8.0-openjdk-devel-1:1.8.0.275.b01-1.el8_3.x86_64 ttmkfdir-3.0.9-54.el8.x86_64 xorg-x11-fonts-Type1-7.5-19.el8.noarch 완료되었습니다! [sidepower@localhost java]$ |
■ 설치 확인
[sidepower@localhost java]$ java -version openjdk version "1.8.0_275" OpenJDK Runtime Enviroment (build 1.8.0_275-b01) OpenJDK 64-Bit Server VM (build 25.275-b01, mixed mode) [sidepower@localhost java]$ javac -version javac 1.8.0_275 [sidepower@localhost java]$ |
■ java 컴파일 , 실행 테스트
[sidepower@localhost java]$ vi helloJava.java public class helloJava { public static void main(String[] args) { System.out.println("hello world"); } } [sidepower@localhost java]$ ll 합계 4 -rw-rw-r--. 1 sidepower sidepower 108 2월 helloJava.java [sidepower@localhost java]$ [sidepower@localhost java]$ javac helloJava.java [sidepower@localhost java]$ ll 합계 8 -rw-rw-r--. 1 sidepower sidepower 423 2월 helloJava.class -rw-rw-r--. 1 sidepower sidepower 108 2월 helloJava.java [sidepower@localhost java]$ java helloJava hello world [sidepower@localhost java]$ |
감사합니다.
반응형
'IT > LINUX' 카테고리의 다른 글
리눅스 vi(vim) 복사 붙여넣기 주석 자동으로 생기는 현상과 계단 현상 (0) | 2021.03.15 |
---|---|
리눅스 ^M 또는 특수문자(CRLF) 제거 치환하기 (0) | 2021.03.03 |
리눅스 gzip 명령어 사용법 . 다름이름으로 압축풀기 (4) | 2021.02.02 |
리눅스 find 명령어 사용법 (4) | 2021.01.31 |
리눅스 시간 atime ctime mtime amin cmin mmin 개념 정리 (4) | 2021.01.15 |
댓글