150 likes | 303 Views
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
E N D
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 • Our objective is to remove this wall • Course will focus on where Java approach differs from our traditional programming Java - Introduction (c)http://www.geocities.com/idmssql
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 Java - Introduction (c)http://www.geocities.com/idmssql
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! Java - Introduction (c)http://www.geocities.com/idmssql
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 Java - Introduction (c)http://www.geocities.com/idmssql
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 Java - Introduction (c)http://www.geocities.com/idmssql
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++ Java - Introduction (c)http://www.geocities.com/idmssql
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 Java - Introduction (c)http://www.geocities.com/idmssql
Mechanics Comments /** * 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 } } Class name (MUST match file name) Main method (starting point) Line comment Braces ‘{}’ - start & end of class and methods Java - Introduction (c)http://www.geocities.com/idmssql
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 Java - Introduction (c)http://www.geocities.com/idmssql
Compilation Javac - the compiler from Sun HellloWorld.java Source Code suffix HellloWorld.class Byte Code Java Virtual Machine Run time 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 Java - Introduction (c)http://www.geocities.com/idmssql
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... Java - Introduction (c)http://www.geocities.com/idmssql
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!!! Java - Introduction (c)http://www.geocities.com/idmssql
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 Java - Introduction (c)http://www.geocities.com/idmssql
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 Java - Introduction (c)http://www.geocities.com/idmssql