javanitrousio

How do you preview/ run a Java program in Nitrous.IO?


I am just starting to use Nitrous.IO and I can't seem to find any information on the web on how to run Java programs you make in it. Any help on how to run a java app made in Nitrous would be a huge help.


Solution

  • You can check the version of Java by running java -version, which shows Java SE is installed. This does not include all of the components of JDK8, but you can still build Java apps on it. Take a look at the JDK8 diagram for an overview of the components included.

    To build a simple hello world app, create a new file titled HellowWorldApp.java with the following contents:

    /**
     * The HelloWorldApp class implements an application that
     * simply prints "Hello World!" to standard output.
     */
    class HelloWorldApp {
        public static void main(String[] args) {
            System.out.println("Hello World!"); // Display the string.
        }
    }
    

    Once saved, run the following command to build a class file:

    javac HelloWorldApp.java
    

    You should now have a file named HelloWorldApp.class. Run this application with the following command:

    java HelloWorldApp
    

    Currently you can utilize this on any box template on Nitrous, but there will be full Java support in the near future.