Setup Java Development Environment in Remote Ubuntu Desktop on Oracle Cloud

In this blog post we will setup Java development environment in Remote Desktop created based on Ubuntu server on Oracle Cloud.

In my previous blog posts ( part-i, part-ii), I have shown you how to setup the free Ubuntu based remote desktop on Oracle cloud using Ampere A1 processor. Now we will install JDK, Java IDEs , VS Code , Node JS and Docker software which enables us to develop Java and JavaScript based applications.

Since Ampere A1 processor is ARM architecture based we need to install ARM architecture supported software only.

For installing Java and Maven software we will use software called SDKMAN.

With SDKMAN, we can easily install JDK’s from different vendors and switch between versions and vendors. SDKMAN will take care of installing Java based on your processor architecture.

Using SDKMAN you can install lot of other libraries. Please check the complete list here

Installing SDKMAN

Open your terminal and enter following command to download.

curl -s "https://get.sdkman.io" | bashCode language: Java (java)

...
Set version to 5.16.0 ...
Set native version to 0.0.15 ...
Attempt update of interactive bash profile on regular UNIX...
Attempt update of zsh profile...



All done!


You are subscribed to the STABLE channel.

Please open a new terminal, or run the following in the existing one:

    source "/home/suresh/.sdkman/bin/sdkman-init.sh"

Then issue the following command:

    sdk help

Enjoy!!!
Code language: Java (java)

Follow the on-screen instructions to complete the installation.

source "/home/suresh/.sdkman/bin/sdkman-init.sh"Code language: Java (java)

You can verify the installation of sdkman with following command.

sdk versionCode language: Java (java)

If the installation was successful, the version should be displayed. Something like:

sdkman 5.16.0Code language: Java (java)

Installing Java

Next let’s install Java

Following command lists all the JDK’s that can be installed

sdk list java Code language: Java (java)

The above command show lists like below.

================================================================================
Available Java Versions for Linux ARM 64bit
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 AdoptOpenJDK  |     | 8.0.275+1.hs | adpt    |            | 8.0.275+1.hs-adpt   
               |     | 8.0.252.hs   | adpt    |            | 8.0.252.hs-adpt     
 Corretto      |     | 19           | amzn    |            | 19-amzn             
               |     | 19.0.1       | amzn    |            | 19.0.1-amzn         
               |     | 17.0.5       | amzn    |            | 17.0.5-amzn         
               |     | 17.0.4       | amzn    |            | 17.0.4-amzn         
               |     | 11.0.17      | amzn    |            | 11.0.17-amzn        
               |     | 11.0.16      | amzn    |            | 11.0.16-amzn        
               |     | 8.0.352      | amzn    |            | 8.0.352-amzn        
               |     | 8.0.342      | amzn    |            | 8.0.342-amzn        
 Dragonwell    |     | 17.0.5       | albba   |            | 17.0.5-albba        
               |     | 17.0.4       | albba   |            | 17.0.4-albba        
               |     | 11.0.17      | albba   |            | 11.0.17-albba       
               |     | 11.0.16      | albba   |            | 11.0.16-albba       
               |     | 8.0.352      | albba   |            | 8.0.352-albba       
               |     | 8.0.345      | albba   |            | 8.0.345-albba       
 GraalVM       |     | 22.3.r19     | grl     |            | 22.3.r19-grl        
               |     | 22.3.r17     | grl     |            | 22.3.r17-grl        
               |     | 22.3.r11     | grl     |            | 22.3.r11-grl        
               |     | 22.2.r17     | grl     |            | 22.2.r17-grl        
               |     | 22.2.r11     | grl     |            | 22.2.r11-grl        
               |     | 22.1.0.r17   | grl     |            | 22.1.0.r17-grl      
               |     | 22.1.0.r11   | grl     |            | 22.1.0.r11-grl      
               |     | 22.0.0.2.r17 | grl     |            | 22.0.0.2.r17-grl    
               |     | 22.0.0.2.r11 | grl     |            | 22.0.0.2.r11-grl    
               |     | 21.3.3.r17   | grl     |            | 21.3.3.r17-grl      
               |     | 21.3.3.r11   | grl     |            | 21.3.3.r11-grl      
               |     | 21.3.3.1.r17 | grl     |            | 21.3.3.1.r17-grl    
               |     | 21.3.3.1.r11 | grl     |            | 21.3.3.1.r11-grl    
               |     | 21.3.2.r17   | grl     |            | 21.3.2.r17-grl      
               |     | 21.3.2.r11   | grl     |            | 21.3.2.r11-grl      
 Java.net      |     | 20.ea.26     | open    |            | 20.ea.26-open       
               |     | 20.ea.25     | open    |            | 20.ea.25-open       
               |     | 20.ea.24     | open    |            | 20.ea.24-open       
               |     | 20.ea.23     | open    |            | 20.ea.23-open       
               |     | 20.ea.22     | open    |            | 20.ea.22-open       
               |     | 19           | open    |            | 19-open             
               |     | 19.0.1       | open    |            | 19.0.1-open         
               |     | 11.0.12      | open    |            | 11.0.12-open        
               |     | 8.0.302      | open    |            | 8.0.302-open        
 Liberica      |     | 19.fx        | librca  |            | 19.fx-librca        
               |     | 19.0.1.fx    | librca  |            | 19.0.1.fx-librca    
               |     | 19.0.1       | librca  |            | 19.0.1-librca 
.....  Code language: Java (java)

Using identifier shown in above table, we can install the required JDK’s

The generic command to install java is

sdk install java <identifier>Code language: Java (java)

Let’s install the GraalVM Java 17 and 11 versions

sdk install java 22.3.r17-grCode language: Java (java)
Downloading: java 22.3.r17-grl

In progress...

#####################################################################       Code language: Java (java)

You can verify the installed Java versions by running the below command .

The status column indicates the installed status

sdk list java Code language: Java (java)
================================================================================
Available Java Versions for Linux ARM 64bit
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 AdoptOpenJDK  |     | 8.0.275+1.hs | adpt    |            | 8.0.275+1.hs-adpt   
               |     | 8.0.252.hs   | adpt    |            | 8.0.252.hs-adpt     
 Corretto      |     | 19           | amzn    |            | 19-amzn             
               |     | 19.0.1       | amzn    |            | 19.0.1-amzn         
               |     | 17.0.5       | amzn    |            | 17.0.5-amzn         
               |     | 17.0.4       | amzn    |            | 17.0.4-amzn         
               |     | 11.0.17      | amzn    |            | 11.0.17-amzn        
               |     | 11.0.16      | amzn    |            | 11.0.16-amzn        
               |     | 8.0.352      | amzn    |            | 8.0.352-amzn        
               |     | 8.0.342      | amzn    |            | 8.0.342-amzn        
 Dragonwell    |     | 17.0.5       | albba   |            | 17.0.5-albba        
               |     | 17.0.4       | albba   |            | 17.0.4-albba        
               |     | 11.0.17      | albba   |            | 11.0.17-albba       
               |     | 11.0.16      | albba   |            | 11.0.16-albba       
               |     | 8.0.352      | albba   |            | 8.0.352-albba       
               |     | 8.0.345      | albba   |            | 8.0.345-albba       
 GraalVM       |     | 22.3.r19     | grl     |            | 22.3.r19-grl        
               | >>> | 22.3.r17     | grl     | installed  | 22.3.r17-grl        
               |     | 22.3.r11     | grl     | installed  | 22.3.r11-grl        
               |     | 22.2.r17     | grl     |            | 22.2.r17-grl        
               |     | 22.2.r11     | grl     |            | 22.2.r11-grl        
               |     | 22.1.0.r17   | grl     |            | 22.1.0.r17-grl      
               |     | 22.1.0.r11   | grl     |            | 22.1.0.r11-grl      
               |     | 22.0.0.2.r17 | grl     |            | 22.0.0.2.r17-grl    
               |     | 22.0.0.2.r11 | grl     |            | 22.0.0.2.r11-grl    
               |     | 21.3.3.r17   | grl     |            | 21.3.3.r17-grl      
               |     | 21.3.3.r11   | grl     |            | 21.3.3.r11-grl      
               |     | 21.3.3.1.r17 | grl     |            | 21.3.3.1.r17-grl    
               |     | 21.3.3.1.r11 | grl     |            | 21.3.3.1.r11-grl    
               |     | 21.3.2.r17   | grl     |            | 21.3.2.r17-grl      
               |     | 21.3.2.r11   | grl     |            | 21.3.2.r11-grl      
 Java.net      |     | 20.ea.26     | open    |            | 20.ea.26-open       
               |     | 20.ea.25     | open    |            | 20.ea.25-open       
               |     | 20.ea.24     | open    |            | 20.ea.24-open       
               |     | 20.ea.23     | open    |            | 20.ea.23-open       
               |     | 20.ea.22     | open    |            | 20.ea.22-open       
               |     | 19           | open    |            | 19-open             
               |     | 19.0.1       | open    |            | 19.0.1-open         
               |     | 11.0.12      | open    |            | 11.0.12-open        
               |     | 8.0.302      | open    |            | 8.0.302-open        
 Liberica      |     | 19.fx        | librca  |            | 19.fx-librca        
               |     | 19.0.1.fx    | librca  |            | 19.0.1.fx-librca    
               |     | 19.0.1       | librca  |            | 19.0.1-librca       
               |     | 19           | librca  |            | 19-librca           
               |     | 17.0.5.fx    | librca  |            | 17.0.5.fx-librca    
               |     | 17.0.5       | librca  |            | 17.0.5-librca  Code language: Java (java)

Knowing current version of Java

sdk current java
Code language: Java (java)
Using java version 22.3.r17-grlCode language: Java (java)

Switching default version of Java

sdk default java 22.3.r11-grlCode language: Java (java)
Default java version set to 22.3.r11-grl
Code language: Java (java)

Checking the current version of Java after changing default java version

sdk current javaCode language: Java (java)
Default java version set to 22.3.r11-grl
Code language: Java (java)

Installing the Maven

You can list available Maven version with following command

sdk list mavenCode language: Java (java)
================================================================================
Available Maven Versions
================================================================================
     3.8.6               3.3.3                                                  
     3.8.5               3.3.1                                                  
     3.8.4               3.2.5                                                  
     3.8.3               3.2.3                                                  
     3.8.2               3.2.2                                                  
     3.8.1               3.2.1                                                  
     3.6.3               3.1.1                                                  
     3.6.2               3.1.0                                                  
     3.6.1               3.0.5                                                  
     3.6.0               3.0.4                                                  
     3.5.4                                                                      
     3.5.3                                                                      
     3.5.2                                                                      
     3.5.0                                                                      
     3.3.9                                                                      

================================================================================
+ - local version
* - installed
> - currently in use
Code language: Java (java)

Install required Maven version

sdk install maven 3.8.6Code language: Java (java)

Check the Maven installation

mvn --version Code language: Java (java)

If you see the error message like below

Command 'mvn' not found, but can be installed with:
sudo apt install maven
Code language: Java (java)

Run the command to make installed maven, default version

sdk default maven 3.8.6Code language: Java (java)

Installing IntelliJ Idea

Next we will install IntelliJ Idea Community Edition IDE to develop Java applications

Go to IntelliJ Idea download page and download aarch64 tar file

Extract the tar file

sudo tar -xvf ideaIC-2022.3-aarch64.tar -C /opt/Code language: Java (java)

rename the folder

sudo mv /opt/idea-IC-223.7571.182/ /opt/ideaCode language: Java (java)

IntelliJ Idea Linux arm version does not support creating shortcut to program on Desktop

If you want to start the IDE

Open your terminal and run the following command.

/opt/idea/bin/idea.shCode language: Java (java)

To create desktop shortcut you need to create launcher file manually.

Right click on the desktop and click on “Create Launcher” menu option.

In “Create Launcher” window enter following details and click “Ok” button to create desktop shortcut.

  • Name : IntelliJ Idea
  • Description : IntelliJ Idea
  • Command : /opt/idea/bin/idea.sh
  • Icon : /opt/idea/bin/idea.png
  • Terminal : No
  • Type : Application

You can also create launcher by creating “IntelliJIdea.desktop” file and enter following text into it.

[Desktop Entry]
Name=IntelliJ Idea
GenericName=IntelliJ Idea
Comment=
Exec=/opt/idea/bin/idea.sh
Type=Application
Icon=/opt/idea/bin/idea.png
Terminal=falseCode language: Java (java)

Installing Eclipse

If you prefer Eclipse to IntelliJ Idea

Go to https://www.eclipse.org/downloads/ page and download the AArch64 version of the tar of tar file.

Unpack the installer

sudo tar -xvf eclipse-inst-jre-linux-aarch64.tar.gz Code language: Java (java)

Go to the extracted “eclipse-installed” folder and click on the “eclipse-inst” file to open the installer.

From the installer choose one of below options

Eclipse IDE for Java Developer

or

Eclipse IDE for Enterprise Java Developer

Click on the “Install” button

Installing VS Code

Go to https://code.visualstudio.com/Download# and download the arm64 deb package.

Install VS Code with following command.

sudo dpkg -i code_1.74.0-1670258379_arm64.debCode language: Java (java)

Installing Docker

Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.

sudo apt updateCode language: Java (java)
sudo apt install \
    ca-certificates \
    curl \
    gnupg \
    lsb-releaseCode language: Java (java)
sudo mkdir -p /etc/apt/keyrings
Code language: Java (java)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgCode language: Java (java)
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullCode language: Java (java)

Grant read permission for the Docker public key file before updating the package

sudo chmod a+r /etc/apt/keyrings/docker.gpg

sudo apt-get updateCode language: Java (java)

Install Docker Engine

To install the latest version, run following command

sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-pluginCode language: Java (java)

The Docker daemon always runs as the root user . other users can access only access it using “sudo”

If you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group. 

Create docker group

sudo groupadd dockerCode language: Java (java)

Add your user to the docker group.

sudo usermod -aG docker $USERCode language: Java (java)

You can run the following command to activate the changes to groups

newgrp dockerCode language: Java (java)

You can also Log out and log back in so that your group membership is re-evaluated.

Verify that you can run docker commands without sudo.

docker run hello-worldCode language: Java (java)

Installing Docker compose

sudo curl -L "https://github.com/docker/compose/releases/download/v2.14.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Code language: Java (java)

Apply executable permissions to docker-compose binary

sudo chmod +x /usr/local/bin/docker-composeCode language: Java (java)

Test with by running

docker-compose  --helpCode language: Java (java)

Starting the docker service on system startup

sudo systemctl enable docker.service
sudo systemctl enable containerd.serviceCode language: Java (java)

Installing NVM

NVM is used to install and switch between different versions of Node JS

From Terminal  run nvm installer script

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bashCode language: Java (java)

The nvm installer script creates an environment entry to the login script of the current user. You can either log out and log in again to load the environment or execute the below command to do the same.

source ~/.bashrc Code language: Java (java)

check the installation with following command

nvm -vCode language: Java (java)

Installing Node using NVM

Open your terminal and use following commands to install the Node JS.

You can list all available Node JS version with nvm

nvm list-remoteCode language: Java (java)

install the latest lts version

nvm install --ltsCode language: Java (java)

install specific version

nvm install <version-number>Code language: Java (java)

Switching between Node versions

To use the latest version of LTS

nvm use --ltsCode language: Java (java)

To use specific version of Node

nvm use <version-number>Code language: Java (java)

Now the remote desktop is ready for the Java and JavaScript related application development.

You might also interested in

Similar Posts