Download Introduction - Seneca - School of Information & Communications

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

Go (programming language) wikipedia , lookup

Library (computing) wikipedia , lookup

C Sharp syntax wikipedia , lookup

Object-oriented programming 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
BPJ444:
Business Programming
Using Java
Introduction
Tim McKenna
Introduction
The Focus of BPJ444
 What is Java?
 The Sun Java 2 Platform
 Getting Started with Java Programming
 The IBM i5, iSeries, AS/400 Java Platform

The Focus of BPJ444


Java programming skills (85%)
IBM tool and platform (15%)
– IBM WebSphere Development Studio Client for iSeries
which is based on Eclipse IDE. Use Eclipse.
– IBM iSeries as a database platform

preparation for other courses
– DOMINO, iSeries Practicum, Web Services
Architecture
What is Java?






invented at Sun Microsystems in 1991 by
James Gosling, a Canadian.
named the new language “Oak” after looking
out his office window
later renamed “Java” following a trademark
search
1994: hey, this Web thing is way cool
May 23, 1995: Java and HotJava browser
officially announced
JDK 1.0 available November, 1995
What is Java?

Java starts with C/C++ language form:
– syntax, semantics, expressions

Java improves C/C++:
– no pointers in Java … hooray
– no memory manglement malloc/free
– Java does automatic “garbage collection”
– strings are objects, not null-terminated arrays
– int, long, float are the same everywhere
– out of bounds array index checking at run time
Java cleans up C++

no operator or keyword overloading
– things mean what you think they mean

no header files
– Java uses classes and packages


no multiple inheritance
no standalone functions
– in Java, all methods belong to a class

no preprocessor
– everything is in the Java language

no structures or unions
– everything is in a class
Java is better
for Web, business & application
programming (no memory manglement)
 safer than C & C++ (no pointer stuff)
 rich library of programming features
 more portable across platforms
 downloadable Java applets can run

– in any browser (unlike ActiveX)
– safely in the Java security “sandbox”
(unlike ActiveX)
Java formula
 Java
= C++
– complexity and ambiguity
+ security and portability
Java is Object Oriented




focus is on objects, i.e. classes of things
objects have attributes: fields or variables (data)
objects have behaviour: methods to act on data
Procedural languages like C or COBOL …
– use algorithms to act on data – trusting all other
programs to behave properly and not corrupt data.
– data has no control of programs acting on it
data's only protection is DB constraints
– data and procedures are structurally
independent but functionally dependent
The Sun Java 2 Platform

Java mantra: “write once, run anywhere”
– the same code runs on any platform

also: run anytime
–
–
–
–

same code runs on the same platform over time
today on WinXP/Pentium 32bit CISC
tomorrow on Win?? & Itanium 64 bit EPIC
(this has always been OS/400 strength…
1979 S/38 *PGM objects run on current iSeries)
criticism: “write once, test/debug everywhere”
– with Java 2, this is rarely an issue anymore.
– with C++, it is still true
The Sun Java 2 Platform
- how does it do that?

use of bytecode to achieve portability
– .java source code ‘compiled’ into .class bytecode
– virtual assembler language


Java Virtual Machine interprets standard
bytecode and runs it on a specific platform
OS/hardware platform implements its own JVM
– e.g. OS/400, Wintel, Mac, Unix, Linux
– each have different Java Virtual Machines (JVM) to
run standard bytecode on their local OS / hardware
– some just-in-time compilation for speed
– performance issues everywhere except OS/400
The Sun Java 2 JDK

terminology
– JRE: Java Runtime Environment
– JDK: Java Development Kit
– SDK: Software Development Kit (old name for JDK)




Java compiler:
> javac classfile.java
Java interpreter (JVM)
> java classfile
other command-line tools (e.g. javadoc, jar)
versions: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5
How to install Java 2 JDK?
 http://java.sun.com
–link: J2SE Core Java

common problems in installation
– path name (“command unknown”)
– classpath name (“class file not found”)
– upper/lower case names


solutions: JDK documentation, General
Information, Installation Notes
see BPJ444 web site for installation notes
How to code, compile and run
a Java program?





Java 2 JDK Environment (Windows Platform)
notepad or TextPad: type in Java source code
compile source code:
> javac HelloWorld.java
run program:
> java HelloWorld
Eclipse: create a project, enter code (with assistance),
save a file (auto compiled), run from inside Eclipse…
it's an Integrated Development Environment
Getting Started with Java
Programming






Two Examples: a Java application and a Java applet
The Anatomy of a Java Application
Java Applets and the Internet
The Anatomy of a Java Applet
The Java Tutorial (online): http://java.sun.com
see the Introduction web page
Definitions

package: a group of related classes
– sometimes called a "library" of classes

Java API: Application Program Interface
– Java's many packages with many
capabilities
– all documented with javadoc utility into
HTML pages

base package “java.lang” is automatically
imported into every Java program
Some Examples

a Java application (console-based)
– HelloWorld.java
– HelloWorld2.java
– command line tools: javac, java

a Java applet
– HelloWorldApplet.java
– HelloWorlddemo2.html
– tools: javac, appletviewer
The Anatomy of a Java Application


Example: HelloWorld.java
three types of comments
– line, multi-line, and javadoc


keywords: public, static, private
use of API specification
– names: System, out, println
– package name: java.lang

the javadoc command:
– > javadoc HelloWorld.java
– > runJavadoc.bat (in Week01.zip) will organize
and document all .java files in a directory
The Anatomy of a Java Applet






a Java program that runs in a web page
subject to security restrictions
Example: HelloWorldApplet.java
keyword: import
use of API specification
- names: java.applet.Applet, paint
names: packages, classes, method, objects
tools: appletviewer, Firefox
IBM i5, iSeries, AS/400
Java Platform



Sun JDK compliant
the QShell Interpreter and Integrated File
System (IFS) – simulated UNIX environment
AS/400 Toolbox for Java
– Java classes developed by IBM to access OS/400
resources

performance optimization
– the JVM is integrated with OS/400 in microcode
– OS/400 Java commands: CRTJVAPGM, RUNJVA
Java and IBM eServer iSeries




Approach 1: use of a workstation (or desktop)
locally develop Java code, e.g. using IBM WDSC
ftp the Java code to the IBM iSeries server
Integrated File System e.g. /bpj444demo
use iSeries QShell (STRQSH) to compile & run:
cd /bpj444demo
set CLASSPATH .
javac HelloWorld2.java
java HelloWorld2
Java and IBM eServer iSeries



Approach 2: Use of IBM Operations
Navigator
workstation development of Java code
“drag and drop”
– from Windows Explorer to Operations Navigator
– use an iSeries Integrated File System directory


RIGHT click on HelloWorld2.java
to compile the code
RIGHT click on HelloWorld2.class
to run the code
Java and IBM eServer iSeries



Approach 3: green screen server environment
use SEU or EDTF to build Java programs
use CL commands to compile and run Java
programs. e.g.
===> RUNJVA CLASS(HelloWorld2)
CLASSPATH('/bpj444demo')
===> GO CMDJVA
WebSphere Development Studio
Client for iSeries

build on Eclipse technology
– open source IDE: www.eclipse.org
tool for developing Java, etc. code
 built-in special support for OS/400 Java
- AS/400 Toolbox for Java
- Enterprise Toolkit for AS/400
 www.ibm.com/software/ad/wdt400/
