Skip to content

Assignment 0

yoavg edited this page Mar 10, 2017 · 1 revision

Install Java

Install the Java Development Kit. (JDK) Download the installation file from here and run it.

Make sure that your installation is working

Open up a terminal window, and issue the following commands:

java -version

javac -version

You should see output similar to:

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Server VM (build 24.51-b03, mixed mode)

and

javac 1.7.0_51

Write, Compile and Run a simple program

  1. Create a file named HelloWorld.java
  2. Enter the following content:
public class HelloWorld {
  public static void main(String[] args) {
    for (int i = 0; i < 5; i++) {
       System.out.println("Hi");
    }
  }
}
  1. Compile the program using: javac HelloWorld.java
  2. Verify that a corresponding HelloWorld.class file is created.
  3. Run the compiled program: java HelloWorld

You should see the output

Hi
Hi
Hi
Hi
Hi

Make sure you know about the Coding Style

Read and follow the instructions in the CodingStyle page.

Clone this wiki locally