Introduction
What is/isn't Java?
 | IS
 | a simple, object-oriented, distributed, interpreted, robust,
secure, architecture-neutral, portable, high-performance,
multithreaded, dynamic, "buzzword-compliant",
general-purpose programming language |
 | "C++ done right" |
|
 | IS NOT
 | "real-time" |
 | for Games like DOOM or Quake |
|
Java History
 | Origins - Oak project and conversion to WWW
http://java.sun.com/features/1998/05/birthday.html |
 | JavaScript vs Java
 | JavaScript is...
 | A quick and dirty scripting language for automation
(loosely typed) |
 | Object-Based (not Object-Oriented) |
 | Depends on a Web Browser for much infrastructure support
and security |
 | "Standardized" from Netscape JavaScript and
Microsoft JScript (ECMA 262 - ECMAScript)
|
|
 | Java is...
 | Full-fledged programming language (strictly typed) |
 | Object-Oriented (has strict notions of inheritance,
visibility) |
 | Comes with own VM as support and security |
 | Not Standardized (Controlled by Sun, who is trying to
"Standardize" yet remain in control of its
future) |
|
|
 | JDK 1.0x, 1.1, 2.0 |
Version |
Highlights |
1.0 |
Debute in 1995 |
1.02 |
Bug fixes of
1.0. AWT Event Model introduced |
1.1 |
AWT Event Model fixed |
1.2 |
Java2 platform
 | javax Extensions |
 | JFC (Swing, Java2D, Accessibility) |
 | Collections API |
 | More tools in java.util, more control over GC |
|
1.3 |
|
 | 100% "Pure Java" and legal implications
 | Condensed Version
 | Microsoft licenses Java Technology from Sun |
 | Microsoft implements Java and adds own Java language
extensions and punts JNI for J/Direct |
 | Sun sues Microsoft for attempting to fragment or subvert
the Java "platform" (via copyright infringment) |
|
 | Ramifications taken
 | Microsoft has to add support for JNI |
 | VisualJ++ has to warn users if they enable Microsoft's
extensions |
 | VisualJ++ has to default to disabling Microsoft's
extensions |
|
 | Clean Room Java Technology
 | HP Chai |
 | Travsvirtual Kaffe |
 | Open Source Japhar |
|
|
 | Specialized versions
 | Java2 Platform, Enterprise Edition |
 | Consumer and Embedded Technologies
 | Java2 Platform, Micro Edition |
 | Jini |
 | PersonalJava |
 | EmbeddedJava |
 | Java Card |
 | Java Phone |
 | Java TV |
 | ... The list goes on and on... |
|
|
Applet Example
 | Java and HTML |
Useful General Syntax
<APPLET
CODE="applet-class" WIDTH=width-in-pixels
HEIGHT=height-in-pixels [ARCHIVE="jar-filename"]
[CODEBASE="where-is-the-root-location-of-the-applet"]
[ALIGN="left,right,top,bottom,center..."]
[ALT="Text-browser-displays-if-applet-can't-be-run]
...other applet options
>
[<PARAM NAME=applet-parameter-1 VALUE=value1]
[<PARAM NAME=applet-parameter-2 VALUE=value2]
...
HTML that browser displays if applet did not run
</APPLET>
 | Must specify
 | CODE
 | where is the applet class located? |
 | MyApplet[.class] |
|
 | WIDTH, HEIGHT
 | how big an area in the browser does the applet get? |
|
|
 | Useful
 | CODEBASE
 | Applets can depend on this to load images using
relative URL |
|
 | ALT
 | Be nice to surfers that don't turn on Java! |
|
 | ALIGN
 | How the applet is positioned within the browser |
|
 | ARCHIVE
 | If applet is in a JAR file, specify where the JAR
file is
|
|
|
 | Applet embedded in HTML Example
 | HelloWorldApplet.java |
 | HelloWorldApplet.html |
|
 | Differentiate between Applet and Application
 | Applets and Application trade off between portability and
security
 | Applets are portable code from anywhere, hence untrusted
and highly restricted |
 | Application are local, hence inherently trusted and
loosely restricted |
|
 | Later on, we'll turn our previous "Hello World" class
into one that can be both an applet and application (with
restrictions) |
|
Java Architecture Overview
Language (Details later)
 | Features
 | "Write once, run anywhere"
 | Java Source code compiles to intermediate Jave Bytecode |
 | Java Bytecode targets the Java Virtual Machine (JVM),
not Native Machine |
 | Java Bytecode runs anywhere the JVM runs |
|
 | Security
 | Java Bytecode checked/verified before being executed in
the JVM |
|
|
 | Java Basics
 | Object Oriented
 | Java consists of Classes, Fields, Methods |
|
 | Similar to C++ in semantics and syntax |
 | Easier to use; harder to shoot yourself |
 | Fewer grungy details |
|
 | Sample Java Code
 | Using our earlier applet... upgrade it |
 | How to make a class that's both an Application and Applet
depending on context
 | HelloWorldApplet2.html |
 | HelloWorldApplet2.java |
|
|
API (Details later)
 | API vs Java
 | Java - the programming language |
 | API - Interfaces for programmers to use, all written for and in
Java
 | Jini, JavaOS - "Other" API |
 | Servlet, JavaBeans Activation Framework, JavaMail -
"Other" API that extend the core Java API |
 | Collection, Java Foundation Classes (Swing, Java2D,
Accessibility) - "Other" API that extend and
is distributed with the core Java API |
|
|
Using Java
JDK versions
 | Browse the Javasoft website for the most recent JDK/Java platform
alignments! http://www.javasoft.com/products |
 | Standard Tools
 | java - the interpreter
 | Given a class, java tries to run the method that has the
signature
public static void main(String[]) |
 | The class is specified by name and also package path if
it exists |
|
 | javac - the compiler |
 | appletviewer - test applets |
 | javadoc - HTML Documentation generator |
 | jdb - debugger |
 | others - jar, javah, javap, rmic |
 | applet/document viewer - Netscape, IE, HotJava, etc. |
|
Other Tools
 | IDEs
 | Advantages over bare-bones JDK
 | No makefiles and dependencies to maintain |
 | More powerful and visually intuitive debugging
 | Jump in/out/forward/backward in code |
 | Set/unset breakpoints |
|
 | Advanced Debugging support for Server/Client like RMI |
 | Creature Comforts
 | Syntax Coloring |
 | Autocompletion |
 | Easy access to help |
|
|
 | Comercial Products
 | Symantec Visual Cafe |
 | Microsoft J++ |
 | IBM VisualAge |
 | Sun JavaStudio and JavaWorkshop |
|
 | Free Products
 | Borland JBuilder |
 | Kawa Java IDE |
 | Emacs JDE |
|
|
 | Others
 | Free VMs - Japhar, KVM |
 | Free APIs - NinjaRMI, GNU classpath |
 | alternative compiler - jikes (from IBM) |
 | jasmin, decompilers, obfuscators |
 | Performance enhancers such as Mocha, JIT, Hotspot |
 | Language extensions: pizza (GJ), polyj |
 | Embedded systems tools: Jump |
|
Books
 | Favorites
 | Flanagan. Java in a Nutshell, Third Edition |
 | Horstmann, Cornell. Core Java 2, Volume 1 |
 | Geary. Graphic Java 2, Mastering the JFC Vol 1 (AWT), Vol 2
(Swing) |
|
 | Official Sun Introductory Books
 | Campione and Walrath, The Java Tutorial, Second Edition |
 | Kanerva, The Java FAQ |
 | Arnold and Gosling. The Java Programming Language, Second
Edition |
|
 | Official Sun Specifications
 | Gosling and Steele, The Java Language Specification |
 | Lindholm, Yellin. The Java Virtual Machine Specification, Second
Edition |
 | Chan, Lee, Kramer. The Java Class Libraries, Second Edition |
|
Links
|