Obsidian/Recognition/Programing/Linux/CentOS/CentOS에 JAVA 설치.md

60 lines
1008 B
Markdown

#Linux
- 기존 자바 삭제
``` Shell
[root login]
rpm -qa | grep java
yum remove [java-1.7.0-openjdk-1.7.0.79-2.5.5.4.el6.x86_64]
```
- 설치
``` Shell
yum install java-1.8.0-openjdk
# yum list java*jdk-devel
# yum install java-1.8.0-openjdk-devel.x86_64
# java -version
```
- 환경변수 등록
``` Shell
readlink -f /usr/bin/java
> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.i386/jre/bin/java
vi /etc/profile
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.i386
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
export JAVA_HOME PATH CLASSPATH
### 변경사항 적용 ###
source /etc/profile
### 확인 ###
echo $JAVA_HOME
echo $PATH
echo $CLASSPATH
```
- HelloWorld.java 컴파일 후 실행 테스트
``` shell
vi HelloWorld.java
public class HelloWorld{
public static void main(String[] args){
System.out.println("Hello World!!");
}
}
javac HelloWorld.java
java -cp . HelloWorld
Hello World!!
```