Aufgabenblatt 01a

Command Line Tools for Java
PI-1 2008/09

The purpose of this assignment is to introduce you to the command line tools for programming in Java and to familiarize you with the process of submitting your solutions via Goya.

Note. For this assignment you may use Eclipse as a text editor, but not (yet) for compiling and executing the program. Rather, you should use the command line tool javac for compiling your .java files and the command line tool java for executing the generated .class files (as it was demonstrated to you in the lecture). Later, for convenience, we will use an integrated development tool, such as Eclipse, to automate this process. But for now it is important that you understand the steps that are involved in editing, compiling and executing Java programs.


Assignment #1:   HelloWorld.java (PR)

Setup a work environment for developing Java programs. Use these tools for re-creating the "Hello World" program from the lecture on your computer. You are expected to use the command line tools javac and java in this assignment (do not use Eclipse!).


Assignment #2:   HelloWorld3.java (PR) (5 points)

Copy the Program from the previous assignment into a new file HelloWorld3.java. Then, use an editor to modify the source code to let the program print the "Hello, World" message 3 times. Compile and run the HelloWorld3 program.

% javac HelloWorld3.java
% java  HelloWorld3
Hello, World!
Hello, World!
Hello, World!

Deliverable: Check in  HelloWorld3.java to Goya!


Assignment #3:   Greetings.java (UE)

Write a program Greetings.java that takes two names as command-line arguments and prints out the greeting specified below.

% java Greetings Alice Bob
Hi, Alice! Have you met my friend Bob?
 

  1. See what happens if, in this program, you omit
  2. See what happens if, in this program, you misspell (e.g. by removing the first letter)
  3. See what happens if you try to execute Greetings.java with

Be prepared to explain the following files in class (we recommend that you bring notes or a printout with you): Greetings.java.


Assignment #4:   Basic Data Types (UE)

What are the results of the following Java expressions? Make sure you can explain why.

Be prepared to explain the solution in class (we recommend that you bring notes or a printout with you).


Submitting results to Goya.  The final task in this set of assignments is to submit the files HelloWorld3.java via the Web submission system. To submit a file, you must be officially registered for the course.

Be sure to read the course  Collaboration Policy.