0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

脳死のうえ CentOS8 で OpenJDK 使って HelloWorld

Posted at

題名の通りやってみます。

#環境確認
OS はインストールして yum update 実行済みです。

# cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)
#

 
#Java インストール

# yum install java
# yum install java-devel
# which java
/usr/bin/java
# java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
#

#初期セットアップ
パスを通します。
/etc/profile の末尾に dirname で返って来た文字列より、最後の /jre/bin を抜いて記載します。

# dirname $(readlink $(readlink $(which java)))
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el8_1.x86_64/jre/bin
# vi /etc/profile
# tail -5 /etc/profile

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el8_1.x86_64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

# source /etc/profile
#

#スクリプト作成
HelloWorld のスクリプトを記載します。

# pwd
/root
# mkdir -v test1
mkdir: ディレクトリ 'test1' を作成しました
# cd test1
# vi HelloWorld.java
# cat HelloWorld.java
class HelloWorld {
   public static void main(String[] args ){
      System.out.println("HelloWorld");
   }
}
#

#コンパイル

# javac HelloWorld.java
# ll
合計 8
-rw-r--r--. 1 root root 411  5月 11 01:17 HelloWorld.class
-rw-r--r--. 1 root root 111  5月 11 01:17 HelloWorld.java
#

#実行

# java HelloWorld
HelloWorld
#

うまくいきました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?