Download Lecture 1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Object-oriented programming wikipedia , lookup

Pwn2Own wikipedia , lookup

Name mangling wikipedia , lookup

Java syntax wikipedia , lookup

Scala (programming language) wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Java (programming language) wikipedia , lookup

Java performance wikipedia , lookup

Transcript
Java Programming
Lecture 1
Instructors:
Fu-Chiung Cheng
(鄭福炯)
Associate Professor
Computer Science & Engineering
Tatung University
email: [email protected]
http:// www.cse.ttu.edu.tw/~cheng
Contents (chapter 1)
Short History
 Java Development tools
 Install JBuilder Tool and Samples
 Getting Started With Java Programming
 Compiling and Running a Java
Application
 Compiling and Running a Java Applet

History

James Gosling

Oak (Embedded consumer electronic
appliances)

Java, May 20, 1995, Sun World

HotJava
 The first Java-enabled Web browser
JDK Versions






JDK 1.02 (1995)
JDK 1.1 (1996)
Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998)
Java 2 SDK v1.3 (a.k.a JDK 1.2, 2000)
Java 2 SDK v1.4 (Dec. 2001)
Java 2 SDK v1.5 (June 2003 ??)
Java Development Tools

Sun JDK

Inprise JBuilder (RAD)

Microsoft Visual J++

Symantec Café (RAD)

Rouge Wave JFactory

Sun Java Workshop

IBM Visual Age for Java (RAD)
Install JBuilder and Samples
Install JBuilder
 Install Sample Programs



Setup JDK 1.2.2 environment

Set classpath=%classpath%;c:\jbbook

Set path=%path%;c:\jdk1.2.2\bin
Check Java Home:

www.javasoft.com
Getting Started with Java
Programming

A Simple Java Application

Compiling Programs

Executing Applications

A Simple Java Applet

Viewing Java Applets

Applications vs. Applets
A Simple Application
Example 1.1
//This application program prints Welcome
//to Java!
public class Welcome
{
public static void main (String[] args)
{
System.out.println("Welcome to Java!");
}
}
Source
Run
Compiling Programs

On command line

javac file.java
Java Source
File
Compiler
Bytecode
Executing Applications

On command line

java classname
Bytecode
Java
Interpreter
on Unix
Java
Interpreter
on Windows
Java
Interpreter
on Sun
Example
javac Welcome.java
java Welcome
output:...
A Simple Applet
Example 1.2
/* This is an example of Java applets */
import java.awt.Graphics;
public class WelcomeApplet
extends java.applet.Applet {
public void paint (Graphics g)
{
g.drawString("Welcome to Java!",10,10);
}
}
Source
Creating an HTML File
<html>
<body>
<applet code="WelcomeApplet.class"
width = 100 height = 40>
</applet>
</body>
</html>
Viewing Java Applets
Applet
Browser with
Java
Interpretation
on Sun
Browser with
Java
Interpretation
on Windows
Applet Viewer Utility
appletviewer htmlfile.html
Example:
appletviewer WelcomeApplet.html
Run Applet Viewer
Applications vs. Applets

Similarities

Differences
Security Restrictions on Applets

Applets are not allowed to read from, or write
to, the file system of the computer viewing the
applets.

Applets are not allowed to run any programs
on the browser’s computer.

Applets are not allowed to establish
connections between the user’s computer
and another computer except with the server
where the applets are stored.