CS 4773 Object Oriented Systems
About the course


Next Topic: The Java Language

Syallabus

First Assignment

What the course is not.

What the course is.

What is Java?

Java is a programming language which is and most importantly ... Java is like C and C++ in a number of ways.

Most notable is what it does not contain:

Setting up your account

Make sure your path includes:
/usr/local/java/jdk1.1.5/bin

Compile with
javac programname.java

Run applications with
java programname

Run applets with
appletviewer programname.java

This assumes that your java source has an HTML heading as a comment.

Test to see that your path is set correctly by executing:
which javac

Ther result should be:
/usr/local/java/jdk1.1.5/bin/javac

First Assignment Example

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class ShowD extends Applet implements ActionListener {
   Label prompt;
   TextField input;
   double val;

   public void init() {
      prompt = new Label("Enter a number");
      add(prompt);
      input = new TextField(20);
      input.addActionListener(this);
      add(input);
      setBackground(Color.cyan);
   }

   public void paint(Graphics g) {
      g.drawString("The number is: "+val,50,80);
      g.drawString("One hundred times the value is: "+100*val,50,110);
      g.drawString("This program was modified by Steven Robbins",50,150);
   }

   public void actionPerformed(ActionEvent e) {
      if (e.getSource() == input) {
         val = Double.valueOf(input.getText()).doubleValue();
         repaint();
      }
   }

}
Compile this with:
javac ShowD.java

This creates a file called ShowD.class

Run this using:
appletviewer ShowD.java

Put it on the web!


Next topic: The Java Language