15
A Programmer's Introduction to Java - from a S/370 user (c) IDMS/SQL News http://www.geocities.com/idmssql

A Programmer's Introduction to Java

Embed Size (px)

DESCRIPTION

A Programmer's Introduction to Java. - from a S/370 user. (c) IDMS/SQL News http://www.geocities.com/idmssql. Purpose. There seems to be a wall between the ‘old’ mainframe guys and the new Javaworld The wall is artificially created using buzzwords as the building blocks - PowerPoint PPT Presentation

Citation preview

Page 1: A Programmer's Introduction to Java

A Programmer's Introduction to Java

- from a S/370 user

(c) IDMS/SQL News http://www.geocities.com/idmssql

Page 2: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

2

Purpose

There seems to be a wall between the ‘old’ mainframe guys and the new Javaworld

The wall is artificially created using buzzwords as the building blocks

Our objective is to remove this wallCourse will focus on where Java approach

differs from our traditional programming

Page 3: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

3

Java - Topics– Buzzwords and the Reality– Basic Data Structures in Java– JSDK from Sun– Arrays – OOP Basics, Classes and Methods– Constructor– File Handling -I/O- Data Streams– GUI - AWT and Swing Components– Method Overloading, Polymorphism– Applets– IDEs - Intgrated Development Environments

Page 4: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

4

What is Java?

“Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable, high-performance, multithreaded, dynamic language” --Sun Microsystems

The words have been faithfully copied from the original article by James Gosling (1995)

Simple meant simpler than C++! Gosling never intended to compare with other platforms or languages!

Page 5: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

5

A more realistic definition:

A C++ like OO language that has a readable syntax and acceptable performance designed to run on several modern platforms.

eg: applications servers, web servers, web browser (embedded in), Mobile phones and ordinary Windows applications

Page 6: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

6

Evolution of Java

James Gosling, Arthur Van hoff, Andy Bechtolsheim. The Original Team in Sun

Originally designed to work in appliances Mutated to a web browser environment (client) Mutated from there to server software, where it

can run on many back-end server platforms without worrying about GUI compatibility problems

Page 7: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

7

Java Syntax

Language syntax itself is simple Data type declarations,

mathematical operations, array definitions , if-else, for loop, do-while etc are not complex

Easier than C++ Though a few idiosyncracies

inherited from C++

Page 8: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

8

Sample Program

/** Hello World in Java */

public class HelloWorld {

public static void main (String args[]) {

System.out.println("Hello S212 World!");

} // end of method main

} // end of class

Page 9: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

9

Mechanics

/** * HelloWorld.java */

public class HelloWorld extends Object{ public static void main(String arguments[]) // Where the program starts { System.out.println(“Hello World"); // Print out message }}

Comments

Class name (MUST match file name)

Main method (starting point)

Line comment

Braces ‘{}’ - start & end of class and methods

Page 10: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

10

Classes and Methods

We see that Java programs are organized as

classes and methods

All Java programs start with a class definition

Classes contain one or more methods

Page 11: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

11

Compilation

Source code is translated to an intermediate “byte code”The byte code is run in a Java Run Time System which is normally known as JVM = Java Virtual Machine

Source Code

Byte Code

Java Virtual Machine

Javac - the compiler from Sun

HellloWorld.java

HellloWorld.class

suffix

Run time

Page 12: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

12

JSDK – Development Kit

Standard Edition is free - from Sun Contains compilers like - Javac - compile - Java - execute - appletviewer – run applets - Javap – dis-assembler - Javadoc - created html based doc - Jar – Java Archive Tool (ZIP) - many smaller tools...

Page 13: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

13

JSDK Good Unlike C, others vendors didn’t bother to make

their own compilers – one is enough! Easy to install and run Documentation available from sun (zip format) Missing : Sun failed to give a simple editor and

test environment; One must go to DOS! And use an editor made by Mr Nobody!!!

Page 14: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

14

Java vs C

Java was designed for a specific purpose C is a more general purpose closer-to-

machine language Java does not produce machine code;

“interpreted” by the Java Run Time (JVM) C produces executable code (*.exe) which

can be run as it is

Page 15: A Programmer's Introduction to Java

Java - Introduction (c)http://www.geocities.com/idmssql

15

Recap

Java is an Object Oriented language suitable for Web and Server based Windows applications

Java SDK from Sun gives you the compiler and Runtime for Java

It’s all about classes and methods