Centos7 java 설치하기
1. 설치
1. jdk 확인
- yum list java*jdk-devel
[root@noel home]# yum list java*jdk-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.kakao.com * extras: mirror.kakao.com * updates: mirror.kakao.com Installed Packages java-1.8.0-openjdk-devel.x86_64 1:1.8.0.252.b09-2.el7_8 @updates Available Packages java-1.6.0-openjdk-devel.x86_64 1:1.6.0.41-1.13.13.1.el7_3 base java-1.7.0-openjdk-devel.x86_64 1:1.7.0.261-2.6.22.2.el7_8 updates java-1.8.0-openjdk-devel.i686 1:1.8.0.252.b09-2.el7_8 updates java-11-openjdk-devel.i686 1:11.0.7.10-4.el7_8 updates java-11-openjdk-devel.x86_64 1:11.0.7.10-4.el7_8 updates [root@noel home]#
2. 설치
- yum install -y java-1.8.0-openjdk-devl.x86_64
2. 환경변수 설정
1. javac 심볼릭링크 위치 확인
- which javac
[root@noel home]# which javac /usr/bin/javac
2. javac 원본파일 위치 확인
- readlink -f /usr/bin/javac
[root@noel home]# readlink -f /usr/bin/javac /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/bin/javac
3. profile 에 환경변수 설정
- vi /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
4. 수정된 내용 적용
- source /etc/profile
5. 환경변수 설정 확인
- echo $JAVA_HOME
[root@noel home]# echo $JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
3. 테스트
1. 클래스 생성
- vim Hello.java
public class Hello { public static void main(String[] args) { System.out.println("hello test"); } }
2. 컴파일
- javac Hello.java
[root@noel home]# ls Hello.class Hello.java
3. 실행
- java Hello
[root@noel home]# java Hello hello test
'Linux-centos > Linux-centos__java' 카테고리의 다른 글
centos에 tomcat 설치하기 (0) | 2019.06.05 |
---|---|
centos 에 java 설치하기 (0) | 2019.06.05 |