Praktische Softwaretechnologie — Exercise 1

Installation von Java

Check first with the following command, whether there is an existing Java installation on your machine:

java -version

If yes, then  the output will be something like the following:

java version "1.7.0_xy"

If the version number is less than 1.5.0 then install a more up-to-date version, please!

Downloading


The Java Development Kit software can be downloaded freely from the Java Webpage of Oracle. The size of the complete software package is 110MB-130MB.

For downloading the software from the Java webpage mentioned before, you should choose the option „Java SE” (=Java Standard Edition) from the menu „Downloads”.

From the different software packages, we will need only for „JDK 7”. We do not need NetBeans or Java EE at all.

You should accept the license agreement and choose the version which match to your hardware configuration (e.g.: i586) and your operating system (e.g.: Windows, Linux, etc).

Installation


In case of Windows, execute the downloaded .exe file. In case of Linux, you should first give execution right to the downloaded file: „chmod +x jdk-xyz.bin” and then execute it in the following way: „ ./jdk-xyz”.

Follow the instructions of the installation. After the installation issue the following command „java –version”. If everything went well, you should get the correct version number as an output.

Create a file HelloWorld.java


Create and edit a file HelloWorld.java in a text editor which should contains the followings:

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

Compilation and Execution

Enter into the directory where the file HelloWorld.java is located and type the following command in the command line for compiling the java source:

javac HelloWorld.java

If everything goes smoothly you will not get any error message and you can find a file HelloWorld.class in the same directory.

You can start the program with the following command:

java HelloWorld

The result/output should be the following line: „Hello World”. You are done with the first exersice! ;-)

Zuletzt geändert: Dienstag, 11. März 2014, 15:39