CSC153, Class 30: Starting Java (once again) Overview: * About Java * A simple Java program * Java in the MathLAN * Lab Notes: * Food! (For visitors, too.) (Sorry about the politically incorrect source) * Read lab J2 for Wednesday * Update to syllabus * Extra credit for Zuk convo and/or talk * Questions on exam 2? What is Java? * Java is an object-oriented programming language Used to create computer programs * Java was developed at Sun Microsystems in mid-1990's * The future of computing is ... + Embedded systems + Large-scale systems * No language is currently good enough for either task: + Easy for programmers to do stupid things + Insufficient modularity for large programs + Ad-hoc libraries and naming systems * Solution: Build it ourselves * In the mid 1990's, the Web was becoming one of the dominant computing applications. + Problem: Mostly data; little programming * Enter marketing: Our embedded language can be the language for the Web, as long as we give it a cool-enough name. * Special aspects of Java: + Designed as a portable language. The same Java program should run the same (except for speed) on any Java-enabled computer. + Java handles memory management issues for you. + Java is "secure"/"sandboxed" + Java is object-oriented + Java is "small" + ON the other hand, the standard Java libraries are *huge* What does a Java program look like? (1) Every Java program involves one or more classes. (2) One of those classes must provide a method named "main". This method is the "director" or "starting point". import java.io.PrintWriter; // Make "PrintWriter" refer to // java.io.PrintWriter import java.io.*; // Do the same for anything in // the java.io "package" // DON'T DO THIS; IT'S BAD STYLE /** * Your first Java program. * * @author Samuel A. Rebelsky * @version 1.0 of March 2003 */ public class Sample { /** * Your first procedure. */ public static void main(String[] args) { PrintWriter out; out = new PrintWriter(System.out, true); out.println("Hello."); } // main(String[]) } // class Sample How do you do all this? * Editing: Use gedit or xemacs * Typing javac: It may not work for you export PATH=$PATH:/usr/java/j2sdk1.4.1_01/bin/