1
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 1 year has passed since last update.

AWS Cloud9でJavaの開発環境を構築する

Last updated at Posted at 2022-04-11

背景・目的

実践

Javaのバージョンを確認

  • 現在のバージョンを確認します。
  • すでに、Java11が入っています。
$ java --version
openjdk 11.0.14.1 2022-02-08 LTS
OpenJDK Runtime Environment Corretto-11.0.14.10.1 (build 11.0.14.1+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.14.10.1 (build 11.0.14.1+10-LTS, mixed mode)
$ 

Java の拡張サポートの有効化とカスタマイズ

  • PreferenceでJava Supportを有効化します。
  • 以下の内容が含まれるようです。

強化された言語サポートを提供して、Javaを使用する際の開発エクスペリエンスを向上させます。 主な生産性機能には、コードの完了、エラーのリンティング、コードレンズ、ブレークポイントやステッピングなどのデバッグオプションが含まれます。
image.png

Gitクライアント

  • Gitクライアントがインストールされているか確認します。
  • 既にインストール済みでした。
$ git --version
git version 2.32.0
$ 

Mavenインストール

  1. wgetでファイルを取得します。
$ pwd
/usr/local/lib
$ 
$ sudo wget https://dlcdn.apache.org/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz
--2022-04-11 13:48:39--  https://dlcdn.apache.org/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8673123 (8.3M) [application/x-gzip]
Saving to: ‘apache-maven-3.8.5-bin.tar.gz’

100%[===========================================================================================================================================>] 8,673,123   --.-K/s   in 0.04s   

2022-04-11 13:48:39 (226 MB/s) - ‘apache-maven-3.8.5-bin.tar.gz’ saved [8673123/8673123]

$ ls
apache-maven-3.8.5-bin.tar.gz  python3.7

2.ダウンロードしたファイルを展開します。

$ sudo tar -xzvf apache-maven-3.8.5-bin.tar.gz 
展開時のログを開く。
``` $ sudo tar -xzvf apache-maven-3.8.5-bin.tar.gz apache-maven-3.8.5/README.txt apache-maven-3.8.5/LICENSE apache-maven-3.8.5/NOTICE apache-maven-3.8.5/lib/ apache-maven-3.8.5/lib/commons-cli.license apache-maven-3.8.5/lib/commons-io.license apache-maven-3.8.5/lib/commons-lang3.license apache-maven-3.8.5/lib/guava.license apache-maven-3.8.5/lib/guice.license apache-maven-3.8.5/lib/jansi.license apache-maven-3.8.5/lib/javax.annotation-api.license apache-maven-3.8.5/lib/javax.inject.license apache-maven-3.8.5/lib/jcl-over-slf4j.license apache-maven-3.8.5/lib/org.eclipse.sisu.inject.license apache-maven-3.8.5/lib/org.eclipse.sisu.plexus.license apache-maven-3.8.5/lib/plexus-cipher.license apache-maven-3.8.5/lib/plexus-component-annotations.license apache-maven-3.8.5/lib/plexus-interpolation.license apache-maven-3.8.5/lib/plexus-sec-dispatcher.license apache-maven-3.8.5/lib/plexus-utils.license apache-maven-3.8.5/lib/slf4j-api.license apache-maven-3.8.5/boot/ apache-maven-3.8.5/boot/plexus-classworlds.license apache-maven-3.8.5/lib/jansi-native/ apache-maven-3.8.5/lib/jansi-native/Windows/ apache-maven-3.8.5/lib/jansi-native/Windows/x86/ apache-maven-3.8.5/lib/jansi-native/Windows/x86_64/ apache-maven-3.8.5/lib/jansi-native/Windows/x86/jansi.dll apache-maven-3.8.5/lib/jansi-native/Windows/x86_64/jansi.dll apache-maven-3.8.5/bin/m2.conf apache-maven-3.8.5/bin/mvn.cmd apache-maven-3.8.5/bin/mvnDebug.cmd apache-maven-3.8.5/bin/mvn apache-maven-3.8.5/bin/mvnDebug apache-maven-3.8.5/bin/mvnyjp apache-maven-3.8.5/conf/ apache-maven-3.8.5/conf/logging/ apache-maven-3.8.5/conf/logging/simplelogger.properties apache-maven-3.8.5/conf/settings.xml apache-maven-3.8.5/conf/toolchains.xml apache-maven-3.8.5/lib/ext/ apache-maven-3.8.5/lib/jansi-native/ apache-maven-3.8.5/lib/ext/README.txt apache-maven-3.8.5/lib/jansi-native/README.txt apache-maven-3.8.5/boot/plexus-classworlds-2.6.0.jar apache-maven-3.8.5/lib/maven-embedder-3.8.5.jar apache-maven-3.8.5/lib/maven-settings-3.8.5.jar apache-maven-3.8.5/lib/maven-settings-builder-3.8.5.jar apache-maven-3.8.5/lib/maven-plugin-api-3.8.5.jar apache-maven-3.8.5/lib/maven-model-3.8.5.jar apache-maven-3.8.5/lib/maven-model-builder-3.8.5.jar apache-maven-3.8.5/lib/maven-builder-support-3.8.5.jar apache-maven-3.8.5/lib/maven-resolver-api-1.6.3.jar apache-maven-3.8.5/lib/maven-resolver-util-1.6.3.jar apache-maven-3.8.5/lib/maven-shared-utils-3.3.4.jar apache-maven-3.8.5/lib/commons-io-2.6.jar apache-maven-3.8.5/lib/guice-4.2.2-no_aop.jar apache-maven-3.8.5/lib/guava-25.1-android.jar apache-maven-3.8.5/lib/javax.inject-1.jar apache-maven-3.8.5/lib/javax.annotation-api-1.2.jar apache-maven-3.8.5/lib/plexus-utils-3.3.0.jar apache-maven-3.8.5/lib/plexus-sec-dispatcher-2.0.jar apache-maven-3.8.5/lib/plexus-cipher-2.0.jar apache-maven-3.8.5/lib/slf4j-api-1.7.32.jar apache-maven-3.8.5/lib/commons-lang3-3.8.1.jar apache-maven-3.8.5/lib/maven-core-3.8.5.jar apache-maven-3.8.5/lib/maven-repository-metadata-3.8.5.jar apache-maven-3.8.5/lib/maven-artifact-3.8.5.jar apache-maven-3.8.5/lib/maven-resolver-provider-3.8.5.jar apache-maven-3.8.5/lib/maven-resolver-impl-1.6.3.jar apache-maven-3.8.5/lib/maven-resolver-spi-1.6.3.jar apache-maven-3.8.5/lib/org.eclipse.sisu.inject-0.3.5.jar apache-maven-3.8.5/lib/plexus-interpolation-1.26.jar apache-maven-3.8.5/lib/plexus-component-annotations-2.1.0.jar apache-maven-3.8.5/lib/maven-compat-3.8.5.jar apache-maven-3.8.5/lib/wagon-provider-api-3.5.1.jar apache-maven-3.8.5/lib/org.eclipse.sisu.plexus-0.3.5.jar apache-maven-3.8.5/lib/commons-cli-1.4.jar apache-maven-3.8.5/lib/wagon-http-3.5.1-shaded.jar apache-maven-3.8.5/lib/jcl-over-slf4j-1.7.32.jar apache-maven-3.8.5/lib/wagon-file-3.5.1.jar apache-maven-3.8.5/lib/maven-resolver-connector-basic-1.6.3.jar apache-maven-3.8.5/lib/maven-resolver-transport-wagon-1.6.3.jar apache-maven-3.8.5/lib/maven-slf4j-provider-3.8.5.jar apache-maven-3.8.5/lib/jansi-2.4.0.jar $ ```

3.配置します。

$ sudo mv apache-maven-3.8.5 /opt/
$ cd /opt/
$ sudo ln -s /opt/apache-maven-3.8.5 apache-maven
$ ls -l
total 4
lrwxrwxrwx  1 root     root       23 Apr 11 14:13 apache-maven -> /opt/apache-maven-3.8.5
drwxr-xr-x  6 root     root       99 Apr 11 13:52 apache-maven-3.8.5
drwxr-xr-x  4 root     root       33 Mar 16 01:52 aws
drwxr-xr-x 21 ec2-user ec2-user 4096 Apr 11 14:07 c9
drwx--x--x  4 root     root       28 Mar 23 11:30 containerd
drwxr-xr-x  2 root     root        6 Aug 16  2018 rh
$ 

4.PATHを通します。

// .bash_profile
MVN_HOME=/opt/apache-maven
PATH=$MVN_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin

$ source ~/.bash_profile 

5.確認します。

$ mvn -version
Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: /opt/apache-maven-3.8.5
Java version: 11.0.14.1, vendor: Amazon.com Inc., runtime: /usr/lib/jvm/java-11-amazon-corretto.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.14.268-205.500.amzn2.x86_64", arch: "amd64", family: "unix"
$ 

参考

1
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
1
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?