Free Tier: Install Spring Boot on an Oracle Linux VM

In this tutorial, use an Oracle Cloud Infrastructure Free Tier account to setup an Oracle Linux virtual machine (VM). Then, install a Spring Boot application and access your new app from the internet. Finally, this tutorial covers all the steps necessary to setup a virtual network for your host and connect the host to the internet. Key tasks include how to:

  • Setup ssh encryption keys to access your Oracle Linux Server.
  • Setup an Oracle Cloud Infrastructure virtual cloud network (VCN) and related network services required for your host to connect to the internet.
  • Install your Oracle Linux VM and connect it to your VCN.
  • Configure Spring Boot on your VM.
  • Connect to your VM from the internet.

Here is a simplified diagram of the setup for your Linux VM.

A diagram of the components needed to run a Spring Boot app on Oracle Cloud Infrastructure

For additional information, see:

1. Create SSH Encryption Keys

Create ssh encryption keys you can use to log into your VM.

  1. Open a terminal window:
    • MacOS or Linux: Open a terminal window in the directory where you want to store your keys.
    • Windows: Right click on the directory where you want to store your keys and select Git Bash Here.
  2. Issue the following OpenSSH command:
    ssh-keygen -t rsa -N "" -b 2048 -C <my-key> -f <my-key>

    The command generates some random text art used to generate the keys. When complete, you should have two files:

    • The private key file: <my-key>
    • The public key file: <my-key>.pub

    You use these files to connect to your Compute instance.

You have generated the required encryption keys.

See Creating a Key Pair for more detailed information on generating ssh encryption keys.

2. Create your Virtual Cloud Network (VCN)

Setup a VCN to connect your Linux instance to the internet. You configure all the components needed to create your virtual network.

  1. From the main landing page, select Set up a network with a wizard. Quick action menu from the main Free Tier landing page
  2. In the Start VCN Wizard workflow, select VCN with Internet Connectivity and then click Start VCN Wizard .
  3. In the configuration dialog, fill in the VCN Name for your VCN. Your Compartment is already set to its default value of <your-tenancy> (root).
  4. In the Configure VCN and Subnets section, keep the default values for the CIDR blocks:

    Notice the public and private subnets have different network addresses.
  5. For DNS RESOLUTION uncheck USE DNS HOSTNAMES IN THIS VCN.Picture shows the USE DNS HOSTNAMES IN THIS VCN option is unchecked.
  6. Click Next.

    The Create a VCN with Internet Connectivity configuration dialog is displayed (not shown here) confirming all the values you just entered.

  7. Click Create to create your VCN.

    The Creating Resources dialog is displayed (not shown here) showing all VCN components being created.

  8. Click View Virtual Cloud Network to view your new VCN.

    Your new VCN is displayed. Now you need to add a security rule to allow HTTP connections on port 8080, the default port for your application.

  9. With your new VCN displayed, click your Public subnet link.

    The public subnet information is displayed with the Security Lists at the bottom of the page. There should be a link to the Default Security List for your VCN.

  10. Click on the Default Security List link.

    The default Ingress Rules for your VCN are displayed.

  11. Click Add Ingress Rules.

    An Add Ingress Rules dialog is displayed.

  12. Fill in the ingress rule with the following information. Once all the data is entered, click Add Ingress Rules.

    Fill in the ingress rule as follows:

    • Stateless: Checked
    • Source Type: CIDR
    • Source CIDR:
    • IP Protocol: TCP
    • Source port range: (leave-blank)
    • Destination Port Range: 8080
    • Description: VCN for applications

    Once you click Add Ingress Rule, HTTP connections are allowed to your public subnet.


To open a different port, replace 8080 in the last step with the port number.
You have successfully created a VCN that will make your applications available from the internet.

3. Install your Oracle Linux VM

Install your Oracle Linux VM to run your Spring Boot application.
  1. Open the Oracle Cloud Infrastructure main menu.
  2. Select Compute then Instances.
  3. From the list of instances screen click Create Instance.

    The Create Compute Instance dialog is displayed. Notice the Show Shape, Network and Storage Options should be expanded to configure the virtual machine.

  4. Fill in the fields for the Create Compute Instance dialog with the following data:

    Initial Options

    • Name of your Instance: <name-for-the-instance>
    • Choose an Operating System: Oracle Linux <current-version>
    • Availability Domain: <select-a-domain>
    • Instance Shape: VM.Standard.E2.1.Micro: Virtual Machine, 1 core OCPU, 1 GB Memory, 0.48 Gbps network bandwidth (the default)

    Configure Networking

    • VIRTUAL CLOUD NETWORK: <VCN-you-created>
    • SUBNET COMPARTMENT: <take-default>
    • SUBNET: <public-subnet-you-created>
    • ASSIGN A PUBLIC IP ADDRESS: Selected/Checked

    Additional Options

    • Boot Volume: All options Unchecked
    • Add SSH Keys: Add the public key file you created in part 1 of this tutorial.
  5. Click Create to create the instance. Provisioning the system may take several minutes.
You have successfully created an Oracle Linux VM .

4. Install and Configure Spring Boot

Next, configure your VM for Spring Boot applications.

Follow these steps to setup your VM so you can build your application:

  1. From the main menu select Compute then Instances.
  2. Click on the link to the instance you just created in the previous step.

    From the Instance Details page look under the Instance Access section. Write down the public IP address the system created for you. You use this IP address to connect to your instance.

  3. Open a Terminal or Command Prompt window.
  4. Change into the directory where you stored the ssh encryption keys you created in part 1.
  5. Connect to your VM with this ssh command
    ssh -i <your-private-key-file> opc@<x.x.x.x>

    Since you identified your public key when you created the VM, this command should log you into your VM. You can now issue sudo commands to install and start your server.

  6. Enable HTTP connection via port 8080.
    sudo firewall-cmd --permanent --add-port=8080/tcp
    sudo firewall-cmd --reload

Install Git

Install Git v2 using the IUS Community Project ( Spring Boot Docker tutorial. Navigate to the current version of Git core package and download to a ~/temp directory. For example, installing the Git 2.2.4 core package looks like this.

  1. For example, downloading the Git RPM might looks like this.
    mkdir temp
    cd ~/temp

    The wget command saves the Git package to the temp directory.

  2. Install the RPM with yum.
    sudo yum install git224-core-2.24.2-1.el7.ius.x86_64.rpm
  3. Test result.
    git --version
    git version 2.24.2

    Git is installed.

Install JDK 8

  1. Install OpenJDK 8 using yum.
    sudo yum install java-1.8.0-openjdk-devel
    java -version
  2. Set JAVA_HOME in .bashrc.

    Update the file:

    vi ~/.bashrc

    In the file, append the following text and save the file:

    # set JAVA_HOME
    export JAVA_HOME=/etc/alternatives/java_sdk

    Activate the above command in the current window.

    source ~/.bashrc

Install Maven 3.6

Install Maven from an Apache mirror. Go to the main Maven site's ( download page. Get the the URL for the latest version and download with wget.

  1. Download the Maven zip file.
  2. Extract the program files.
    sudo tar xvfz apache-maven-3.6.3-bin.tar.gz
  3. Install the program files by moving the files to the /opt directory.
    sudo mv apache-maven-3.6.3 /opt/
  4. Add the Maven path /opt/apache-maven-3.6.3/bin to your PATH environment variable and source your .bashrc.
    vi ~/.bashrc
    export PATH=$PATH:/opt/apache-maven-3.6.3/bin
    source ~/.bashrc

    Maven should now be ready to use.

Build Your Spring Boot Application

Now, build your Spring Boot application.

  1. From your home directory check out the Spring Boot Docker guide with Git:
    git clone
  2. Change into the gs-spring-boot-docker/initial directory.
  3. Edit the file: src/main/java/hello/
  4. Update the code with the following:
    package hello;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    public class Application {
        public String home(){
            return "<h1>Spring Boot Hello World!</h1>";
        public static void main(String[] args) {
  , args);
  5. Save the file.
  6. Use Maven to build the application.
    mvn package

    You should get a message of success.

  7. Run the application.
    java -jar target/gs-spring-boot-docker-0.1.0.jar
  8. Test your application from the command line or a browser.
    • From a new terminal, connect to your VM with your SSH keys and test with curl:
      curl -X GET http://localhost:8080
    • From your browser connect to the public IP address assigned to your VM: http://<x.x.x.x>:8080.

    You should see Spring Boot Hello World! on your VM or in your browser.

Congratulations! You have successfully created a Spring Boot application on your VM.