Hello World in Java

Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities.

Hello world example

In this example we'll illustrate how to compile a "Hello world !" source on a host PC with Ubuntu Linux using javac and run the bytecode result on the Acme board.

The example of code is the usually Sun example:

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

Install the JDK on your Ubuntu PC using Synaptic. The package name is default-jdk and is the latest Open Source version of Java OpenJDK 6.

Compile the Hello.java file typing:

$ javac Hello.java

Open a terminal session on board and type:

debarm:~# apt-get update
debarm:~# apt-get install default-jre

Go back to the Ubuntu terminal session and copy the Hello.class byte code to the board:

$ scp Hello.class root@:/root
root@'s password: 
Hello.class                                   100%  418     0.4KB/s   00:00    

Go to the board and type:

debarm:~# cd /root
debarm:~# java Hello
Hello, world !

Related links