Running a Java Micronaut application in Visual Studio Codespaces

Posted by Brian Porter on May 18, 2020

So you can use (https://sdkman.io) to install any Java version you want (like the Amazon Correto in case you plan on deploying to Elastic Beanstalk):

sdk install java 11.0.7-amzn

However, for most cases you should be fine with the pre-installed OpenJDK 1.8.

Visual Studio Codespaces - Port Forwarding

First you will want to identify which port your application will start and map the port. I was starting my Micronaut application on port 5000 with ./gradlew .

You will want to open the remote explorer (see sidebar in screenshot), add a “Forwarded Port”, and then click on the copy URL icon next to port to get the URL your application will be reachable on (don’t enter the port - it will be forwarded to the one you indicated).

Open the URL in your browser, and you “are in”.

If you made it this far, you may as well follow me: