1: Tuesday, June 5
This session covers the reading in Day 1: 21st Century Java |
Introduction to class and
explanation of the syllabus
Quiz (easy) Demonstration of the “Hello World” Java application Demonstration of the Java Glossary applet What is Programming?
Sun’s web site
|
Download, install, and run the
“Hello, World” program
[working code] |
Introduction of instructors and explanation of the syllabus
Quiz (easy) - distribute print outs
Demonstration of the “Hello World” Java application
Demonstration of the Java Glossary applet
1.0, 1.1, 1.2 (Java 2), 1.3 (the current version of Java 2).
Free download of the current SDK, Software Development Kit at http://www.sun.com
Types of languages | ||||
Object-oriented programming | Procedural | Web scripting | Page description | Data description |
Java, C++, SmallTalk, Objective-C | C, Basic, Fortran, Cobol, Lisp, Perl | JavaScript, VBScript | HTML | XML |
public class HelloWorld
{
public static void main (String[] args)
{
System.out.println("Hello World");
}
}
Programming is the process of creating applications. Although there are visual programming environments, such as Visual Basic, this course focuses on text-based programming.
An application is software that runs on top of the operating system, has a specific purpose, and usually allows the user to interact. An example of an application is Microsoft Word. On the other hand, the software that runs your printer (a "driver") is something for the operating system or an application, rather than for the human user.
Java introduced the concept of applets, which are applications that can run inside of a web browser on the client computer. A web browser is an application.
An applet is a "safe" application that can only run inside of another, very specific application. Some of the key restrictions on an applet
Note: If an applet provider registers a specific applet with a registration company, the "signed applet", if you accept it, can have access to your file system.
Note: A Java application, like any application, does have access to your file system.
A computer platform is the combination of the operating system and the central processing unit (CPU).
Examples of operating systems include
Examples of CPUs include
A standard, compiled application runs machine code that is specific for a platform. Machine code is the raw zeros and ones that a computer "chip" understands. If you want your UNIX application to run on Windows, for example, you must "port" the code and recompile it using a compiler that produces machine code that is "native" to the target CPU.
Java code is different from standard, compiled code. You compile your Java source code into a special language, "bytecode", that a special application, the Java virtual machine (JVM), interprets.
The JVM is an application that emulates a computer. It translates Java bytecode into native machine code.
There is a JVM for Mac OS, UNIX, Linux, and Windows. This means that the same source code should be valid for multiple platforms. You do not need to "port" the application to another platform. It should be "write once, run anywhere", assuming there is a JVM for that platform.
There are even JVMs for smaller platforms, such as the PalmOS that runs on the PalmPilot.
When you use any language, whether it is a computer language or a human language, you have to follow the rules. The term "syntax" refers to the rules of word order and word combination. Some languages have a flexible syntax that lets you say "I like ice cream" as well as "Ice cream I like." Other language are more rigid in their rules. Java syntax is more rigid than, say Perl syntax.
When you use any language, whether it is a computer language or a human language, you make statements, declarations, expressions, and ask questions (test conditions). The words that you use to make statements, declarations, and expressions have meanings. The term "semantics" refers to the meanings of words. Human languages often allow one word to have multiple meanings, depending on the context. For example, the meaning of the word "love" in the sentence, "I love ice cream" is somewhat different from its meaning in "I love my spouse." The slang expression, "He kicked the bucket", for example, could have a literal meaning as well as a metaphorical meaning. A computer language might allow the same word to have multiple meanings, depending on the context, or it might restrict the word to one kind of use. The compiler, unlike a human being, does not tolerate ambiguity for any given context.
For example, Java has certain "reserved words" that you use according to Java's syntax and semantics. The Hello World application consists almost exclusively of reserved words or predefined words:
public class HelloWorld
{
public static void main (String[] args)
{
System.out.println("Hello World");
}
}
The only words that are not reserved words or predefined words are the three variables:
Just as human languages have punctuation in addition to words, so Java has special symbols, such as the curly braces { }, parentheses ( ), the brackets [], the comma separator , the wildcard asterisk *, quotation marks " ", the forward slash /, the backslash \, the dot . and the semicolon ; that completes a statement.
********
Overview of your assignment for Thursday:
_________________________
course
homepage course
calendar