Java

[Note]

For PowerPC machines, see Xubuntu Help Online.

Java, developed by Sun Microsystems, is an interpreted language that is compiled to bytecode. This bytecode can be run on any Java Virtual Machine, making Java a highly portable language. It is object oriented, has similar syntax to C and is designed to be secure.

Installation

Xubuntu supports 1.6 in both Sun and Open Source flavors.

JDK 1.6

Java 1.6 is available and can be installed by following the proceeding directions.

  1. Install the sun-java6-jdk package.

  2. Read the Java license presented. You must accept it to continue.

  3. To get your system to use Sun Java instead of the open-source (but less functional) GIJ that is installed by default, run:

    sudo update-alternatives --config java

    and choose the option that has j2re1.6-sun in it.

Hello World

Enter the following code into a text editor and save it as "Hello.java":

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

Open a terminal and compile your code by typing:

javac Hello.java

. You can then run your code by typing:

java Hello

Integrated Development Environments

Eclipse IDE for Java

The Eclipse platform provides a complete, extensible Java development environment.

  1. Install the eclipse package.

  2. Press ApplicationsDevelopmentEclipse IDE to start using Eclipse.

Netbeans

The Netbeans platform provides a complete, extensible Java development environment.