Build Java 8 development environment on AWS Cloud9

Introduction

Click here for AWS Cloud9 introduction https://qiita.com/tu-kun/items/d7b4f1fa19cc93bc5b75

Target

--People who want to upgrade to Java 8 on AWS Cloud9 --People who are not sure but want to introduce Java 8

How to check the version

Java

$ java -version
java version "1.7.0_181"
OpenJDK Runtime Environment (amzn-x.x.xx.x.xx.amzn1-x86_64 u181-b00)
OpenJDK 64-Bit Server VM (build xx.xxx-b00, mixed mode)

Javac

$ javac -version
javac 1.7.0_181

Check the package

The java8 package is java-1.8.0-openjdk-devel. This is a package that also installs OpenJDK for developers.

$ yum search java-1.8.0-openjdk-devel
Loaded plugins: priorities, update-motd, upgrade-helper
epel                                                                                                                 12509/12509
1045 packages excluded due to repository priority protections
================================================ N/S matched: java-1.8.0-openjdk ================================================
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK API Documentation compressed in single archive
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle

Package introduction

Yum install must be run as the root user, so prefix it with the sudo command.

$ sudo yum install java-1.8.0-openjdk-devel                                                           
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main                                                                                                 | 2.1 kB  00:00:00     
amzn-updates                                                                                              | 2.5 kB  00:00:00     
1045 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.171-7.b10.37.amzn1 will be installed
--> Processing Dependency: java-1.8.0-openjdk(x86-64) = 1:1.8.0.171-7.b10.37.amzn1 for package: 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.37.amzn1.x86_64
--> Processing Dependency: libawt_xawt.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.37.amzn1.x86_64
--> Processing Dependency: libawt_xawt.so()(64bit) for package: 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.37.amzn1.x86_64
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.171-7.b10.37.amzn1 will be installed
--> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.171-7.b10.37.amzn1 for package: 1:java-1.8.0-openjdk-1.8.0.171-7.b10.37.amzn1.x86_64
--> Running transaction check
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-7.b10.37.amzn1 will be installed
amzn-main/latest/filelists_db                                                                             | 5.7 MB  00:00:13     
amzn-updates/latest/filelists_db                                                                          | 1.2 MB  00:00:00     
epel/x86_64/filelists                                                                                     | 7.3 MB  00:00:01     
--> Processing Dependency: copy-jdk-configs >= 1.1-3 for package: 1:java-1.8.0-openjdk-headless-1.8.0.171-7.b10.37.amzn1.x86_64
--> Processing Dependency: lksctp-tools(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.171-7.b10.37.amzn1.x86_64
--> Running transaction check
---> Package copy-jdk-configs.noarch 0:1.2-1.2.amzn1 will be installed
---> Package lksctp-tools.x86_64 0:1.0.10-7.7.amzn1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================
 Package                                Arch              Version                                  Repository               Size
=================================================================================================================================
Installing:
 java-1.8.0-openjdk-devel               x86_64            1:1.8.0.171-7.b10.37.amzn1               amzn-updates             12 M
Installing for dependencies:
 copy-jdk-configs                       noarch            1.2-1.2.amzn1                            amzn-main                13 k
 java-1.8.0-openjdk                     x86_64            1:1.8.0.171-7.b10.37.amzn1               amzn-updates            249 k
 java-1.8.0-openjdk-headless            x86_64            1:1.8.0.171-7.b10.37.amzn1               amzn-updates             39 M
 lksctp-tools                           x86_64            1.0.10-7.7.amzn1                         amzn-main                89 k

Transaction Summary
=================================================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 51 M
Installed size: 144 M
Is this ok [y/d/N]: Y
Downloading packages:
(1/5): copy-jdk-configs-1.2-1.2.amzn1.noarch.rpm                                                          |  13 kB  00:00:00     
(2/5): java-1.8.0-openjdk-1.8.0.171-7.b10.37.amzn1.x86_64.rpm                                             | 249 kB  00:00:05     
(3/5): lksctp-tools-1.0.10-7.7.amzn1.x86_64.rpm                                                           |  89 kB  00:00:02     
(4/5): java-1.8.0-openjdk-devel-1.8.0.171-7.b10.37.amzn1.x86_64.rpm                                       |  12 MB  00:00:15     
(5/5): java-1.8.0-openjdk-headless-1.8.0.171-7.b10.37.amzn1.x86_64.rpm                                    |  39 MB  00:00:16     
---------------------------------------------------------------------------------------------------------------------------------
Total                                                                                            2.3 MB/s |  51 MB  00:00:21     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : copy-jdk-configs-1.2-1.2.amzn1.noarch                                                                         1/5 
  Installing : lksctp-tools-1.0.10-7.7.amzn1.x86_64                                                                          2/5 
  Installing : 1:java-1.8.0-openjdk-1.8.0.171-7.b10.37.amzn1.x86_64                                                          3/5 
  Installing : 1:java-1.8.0-openjdk-headless-1.8.0.171-7.b10.37.amzn1.x86_64                                                 4/5 
  Installing : 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.37.amzn1.x86_64                                                    5/5 
  Verifying  : 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.37.amzn1.x86_64                                                    1/5 
  Verifying  : 1:java-1.8.0-openjdk-1.8.0.171-7.b10.37.amzn1.x86_64                                                          2/5 
  Verifying  : 1:java-1.8.0-openjdk-headless-1.8.0.171-7.b10.37.amzn1.x86_64                                                 3/5 
  Verifying  : lksctp-tools-1.0.10-7.7.amzn1.x86_64                                                                          4/5 
  Verifying  : copy-jdk-configs-1.2-1.2.amzn1.noarch                                                                         5/5 

Installed:
  java-1.8.0-openjdk-devel.x86_64 1:1.8.0.171-7.b10.37.amzn1                                                                     

Dependency Installed:
  copy-jdk-configs.noarch 0:1.2-1.2.amzn1                             java-1.8.0-openjdk.x86_64 1:1.8.0.171-7.b10.37.amzn1      
  java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-7.b10.37.amzn1       lksctp-tools.x86_64 0:1.0.10-7.7.amzn1                    

Complete!

Switch to Java 8

Since AWS uses alternatives for java version control, you need to switch rather than just install it.

The version of java prefixed with * + is the currently applied version. ʻEnter to keep the current selection [+], or type selection number: There is a place to interact with , so enter 2` which is jre-1.8.0.

Java

$ sudo alternatives --config java
There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number: 2

Javac

$ sudo alternatives --config javac

There are 2 programs which provide 'javac'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/javac
   2           /usr/lib/jvm/java-1.8.0-openjdk.x86_64/bin/javac

Enter to keep the current selection[+], or type selection number: 2

Finally, check the version, and if it changes to 1.8.0, you're done.

$ java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-b10)
OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)
$ javac -version
javac 1.8.0_171

Summary

Not only will you be happy with the installation, but don't forget to switch!

Recommended Posts

Build Java 8 development environment on AWS Cloud9
Build a Ruby on Rails development environment on AWS Cloud9
Build a Java development environment on Mac
[Java] Build Java development environment on Ubuntu & check execution
Build Java development environment with VS Code on Mac
Build Java development environment (for Mac)
Build Unity development environment on docker
Install Java development environment on Mac
Java development environment
Java development environment construction memo on Mac
Build an environment with Docker on AWS
Build an Ultra96v2 development environment on Docker 1
Java development environment memo
java development environment construction
Try to build Java8 environment on Amazon Linux2
Build a Laravel environment on an AWS instance
Build a development environment for Docker, java, vscode
Build a Java runtime environment on Sakura VPS
[Beginner] Install java development tool in cloud9 development environment.
Build a Java development environment with VS Code
Build a development environment on AWS EC2 with CentOS7 + Nginx + pm2 + Nuxt.js
Create a Java development environment using jenv on Mac
Memo to build a Servlet environment on AWS EC2
Java development environment construction on Mac-JDK Install (2020 preservation version)
Java development environment (Mac, Eclipse)
Update RVM on AWS Cloud9
Build Java development environment with WSL2 Docker VS Code
How to build Java development environment with VS Code
[Environment construction] Build a Java development environment with VS Code!
Try to build a Java development environment using Docker
Build Java program development environment with Visual Studio Code
Build WebAPP development environment with Java + Spring with Visual Studio Code
[Java development environment construction] Install OpenJDK 11 (Java 11) on macOS with Homebrew.
[Eclipse Java] Development environment setting memo
Play Framework 2.6 (Java) development environment creation
Build a Minecraft server on AWS
Hello World on AWS Lambda + Java
About the current development environment (Java 8)
Build a XAMPP environment on Ubuntu
Build jooby development environment with Eclipse
Java development environment (Mac, VS Code)
Install Cloud9 on Raspberry pi 4 and set up Rails development environment
Build a development environment where Ruby on Rails breakpoints work on Windows
Notes on building Kotlin development environment and migrating from Java to Kotlin
[ev3 × Java] leJOS development environment construction (Eclipse on Mac OSX / bluetooth)
Steps to build a Ruby on Rails development environment with Vagrant
Prepare Java development environment with VS Code
Create Spring Boot development environment on Vagrant
Build Maven repository on AWS S3 service
[Processing x Java] Construction of development environment
Build a PureScript development environment with Docker
Let's create a Java development environment (updating)
What is Java and Development Environment (MAC)
Spring Boot + Docker Java development environment construction
Deploy Java programs on SAP Cloud Platform
Build a Wordpress development environment with Docker
Build Redmine code reading environment on Docker
Run jooby's Eclipse development environment on Gradle
Build OpenCV with Java Wrapper on Ubuntu 18.04
[Personal memo] Java development environment is ready
Build a JMeter environment on your Mac