๋กœ์ผ“๐Ÿพ
article thumbnail

[STEP1] open-jdk 1.8 ์„ค์น˜

# yum install java-1.8.0-openjdk
# yum install java-1.8.0-openjdk-devel

์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด /usr/bin/๊ฒฝ๋กœ์— java๊ฐ€ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

 

* ์ฐธ๊ณ  : ๋ฆฌ๋ˆ…์Šค์—์„œ๋„ JDK์™€ JRE๋Š” ๋ณ„๋„์˜ ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค.

java-๋ฒ„์ „-openjdk ํŒจํ‚ค์ง€๊ฐ€ JRE,

java-๋ฒ„์ „-openjdk-devel ํŒจํ‚ค์ง€๊ฐ€ JDK๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

JDK๊ฐ€ JRE์— ์˜์กด์„ฑ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

yum์œผ๋กœ JDK๋ฅผ ์„ค์น˜ํ•˜๋ผ๊ณ  ํ•˜๋ฉด JRE๋ฅผ ๋จผ์ € ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.


[STEP2] ํ™˜๊ฒฝ๋ณ€์ˆ˜ ๋“ฑ๋ก

/usr/bin/java ๊ฒฝ๋กœ์— ์‹ฌ๋ณผ๋ฆญ๋งํฌ๊ฐ€ ๊ฑธ๋ ค์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์‹ค์ œ ๊ฒฝ๋กœ๋ฅผ ์ฐพ์•„์„œ ํ™˜๊ฒฝ๋ณ€์ˆ˜์— ๋“ฑ๋กํ•ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

# readlink -f /usr/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/bin/java

์‹ค์ œ ๊ฒฝ๋กœ๋ฅผ ์ฐพ์•˜์œผ๋ฉด /etc/profile์„ vi๋กœ ์—ด์–ด์ค๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  JAVA_HOMEPATHCLASSPATH๋ฅผ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค.

//# vi /etc/profile

...

JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar

export JAVA_HOME PATH CLASSPATH

ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ๋“ฑ๋กํ–ˆ๋‹ค๋ฉด ssh์—ฐ๊ฒฐ์„ ์žฌ์‹œ์ž‘ํ•˜๊ฑฐ๋‚˜ source /etc/profile ๋ช…๋ ์–ด๋ฅผ ์ž…๋ ฅํ•ด์ค๋‹ˆ๋‹ค.

๋“ฑ๋กํ•œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๊ฐ€ ์ œ๋Œ€๋กœ ์ ์šฉ๋˜์—ˆ๋Š”์ง€ ํ…Œ์ŠคํŠธํ•ฉ๋‹ˆ๋‹ค.

# echo $JAVA_HOME
# echo $PATH
# echo $CLASSPATH

[STEP3] HelloWorld.java ์ปดํŒŒ์ผ ํ›„ ์‹คํ–‰

# vi HelloWorld.java
public class HelloWorld{
   public static void main(String[] args){
        System.out.println("Hello World!!");
   }
}

HelloWorld.java ํŒŒ์ผ์„ ์ปดํŒŒ์ผํ•˜๊ณ  ์‹คํ–‰์‹œ์ผœ์„œ ํ…Œ์ŠคํŠธํ•ด๋ด…๋‹ˆ๋‹ค.

# javac HelloWorld.java
# java -cp . HelloWorld
Hello World!!

 

 

profile on loading

Loading...