Skip to main content
This doc relates to the below revision of hardware
Mecha Logo

Comet (rev5)

For Pilot users

The all new Mecha Comet

Better in all ways, the next revision of Mecha Comet, coming soon.

Java

Java is a versatile, object-oriented programming language known for its "Write Once, Run Anywhere" capability through its platform-independent bytecode.

Install Java

Launch terminal on your Comet or connect via SSH and run the below command.

$ sudo apt update
$ sudo apt install default-jdk

After installation, verify that Java is properly installed:

$ java -version
$ javac -version

Running an example

Let's create a simple "Hello, World!" program to test Golang on the Comet.

1

Create a new directory, and a new source file for your go program.

$ mkdir hello_world && cd hello_world
$ nano HelloWorld.java
2

Paste the following program in the editor

public class HelloJava {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
3

Now lets compile and run the program.

$ javac HelloWorld.java
$ java HelloWorld
Hello, Java!

Now with java installed, you are ready for compiling and running Java programs ☕️!