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 the correct version of Java:
java -version

should give

java version "1.2.1"
Solaris VM (build Solaris_JDK_1.2.1_02, native threads, sunwjit)
or something similar.

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.

First Assignment Example

/* < Applet code = ShowD
     width = 400 height = 300 >
   < /Applet >
*/

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