Eurécom, 1st semester, 2000
Multimedia Networking: TP I

Setting Up the Development Environment

The purpose of this section is to make sure your environment is set up properly for compiling and running Java programs. Here is your assignment for this section: write a Java program that prints out the word "hello." Follow the steps below.

Directory structure

In this lab, we will place the source code files and their corresponding class files in the same directory, so create a new directory to hold these files.

Environmental Variables

There are two Java executables that you will be using for this lab: the Java compiler, javac, which transforms your source code into byte-code (also called class files), and the Java virtual machine, java, which executes the byte-code. You need to include a path to these executables in order to run them as simple one-word commands, which you can do by executing the following command:

   export PATH=${PATH}:/usr/packages1/java/jdk/bin/

When the Java virtual machine runs, it accesses the CLASSPATH environmental variable to obtain a list of paths that it can search to locate the class files that are referenced in byte-code. You can set the CLASSPATH variable by running the following command:

   export CLASSPATH=.:/usr/packages1/java/jdk/lib/classes.zip
Note the period that is included in the CLASSPATH. It's purpose is to tell the Java virtual machine to check in the current directory when resolving class references.

Hello Program

Now write a simple hello program and store it in the directory you created for this lab.

// Hello.java
public class Hello
{
   public static void main(String argv[])
   {
      System.out.println("hello");
   }
}

Compile the hello program with the following command:

   javac Hello.java

And run your Hello program with the Java virtual machine:

   java Hello

If your program greets you, then you are ready to begin coding the simple TCP client and server.