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.. (read all...)

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 FOX Board G20.

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 the FOX Board G20 and type:

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

Go back to the Ubuntu terminal sessione and copy the Hello.class byte code to the FOX:

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

Go to the FOX and type:

debarm:~# cd /root
debarm:~# java Hello
Hello, world !
 
tutorial/java.txt · Last modified: 2010/01/15 21:40 by tanzox
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki