Download presentation
Presentation is loading. Please wait.
Published byMartha Shaw Modified over 9 years ago
1
BPJ444: Business Programming Using Java Introduction Tim McKenna
2
Introduction n The Focus of BPJ444 n What is Java? n The Sun Java 2 Platform n Getting Started with Java Programming n The IBM i5, iSeries, AS/400 Java Platform
3
The Focus of BPJ444 n Java programming skills (85%) n 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 n preparation for other courses –DOMINO, iSeries Practicum, Web Services Architecture
4
What is Java? n invented at Sun Microsystems in 1991 by James Gosling, a Canadian. n named the new language “Oak” after looking out his office window n later renamed “Java” following a trademark search n 1994: hey, this Web thing is way cool n May 23, 1995: Java and HotJava browser officially announced n JDK 1.0 available November, 1995
5
What is Java? n Java starts with C/C++ language form: –syntax, semantics, expressions n 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
6
Java cleans up C++ n no operator or keyword overloading –things mean what you think they mean n no header files –Java uses classes and packages n no multiple inheritance n no standalone functions –in Java, all methods belong to a class n no preprocessor –everything is in the Java language n no structures or unions –everything is in a class
7
Java is better n for Web, business & application programming (no memory manglement) n safer than C & C++ (no pointer stuff) n rich library of programming features n more portable across platforms n downloadable Java applets can run –in any browser (unlike ActiveX) –safely in the Java security “sandbox” (unlike ActiveX)
8
Java formula n Java = C++ – complexity and ambiguity + security and portability
9
Java is Object Oriented n focus is on objects, i.e. classes of things n objects have attributes: fields or variables (data) n objects have behaviour: methods to act on data n 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
10
The Sun Java 2 Platform Java mantra: “write once, run anywhere” Java mantra: “write once, run anywhere” –the same code runs on any platform n 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) n criticism: “write once, test/debug everywhere” –with Java 2, this is rarely an issue anymore. –with C++, it is still true
11
The Sun Java 2 Platform - how does it do that? n use of bytecode to achieve portability –.java source code ‘compiled’ into.class bytecode –virtual assembler language n Java Virtual Machine interprets standard bytecode and runs it on a specific platform n 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
12
The Sun Java 2 JDK n terminology –JRE: Java Runtime Environment –JDK: Java Development Kit –SDK: Software Development Kit (old name for JDK) n Java compiler:> javac classfile.java n Java interpreter (JVM)> java classfile n other command-line tools (e.g. javadoc, jar) n versions: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5
13
How to install Java 2 JDK? n http://java.sun.com http://java.sun.com –link: J2SE Core Java n common problems in installation –path name (“command unknown”) –classpath name (“class file not found”) –upper/lower case names n solutions: JDK documentation, General Information, Installation Notes Installation NotesInstallation Notes n see BPJ444 web site for installation notes
14
How to code, compile and run a Java program? n Java 2 JDK Environment (Windows Platform) n notepad or TextPad: type in Java source code n compile source code:> javac HelloWorld.java n run program:> java HelloWorld n Eclipse: create a project, enter code (with assistance), save a file (auto compiled), run from inside Eclipse… it's an Integrated Development Environment
15
Getting Started with Java Programming n Two Examples: a Java application and a Java applet n The Anatomy of a Java Application n Java Applets and the Internet n The Anatomy of a Java Applet n The Java Tutorial (online): http://java.sun.com http://java.sun.com n see the Introduction web page Introduction web pageIntroduction web page
16
Definitions package: a group of related classes package: a group of related classes –sometimes called a "library" of classes n Java API: Application Program Interface –Java's many packages with many capabilities –all documented with javadoc utility into HTML pages n base package “java.lang” is automatically imported into every Java program
17
Some Examples n a Java application (console-based) application –HelloWorld.java –HelloWorld2.java –command line tools: javac, java n a Java applet applet –HelloWorldApplet.java –HelloWorlddemo2.html –tools: javac, appletviewer
18
The Anatomy of a Java Application n Example: HelloWorld.java n three types of comments –line, multi-line, and javadoc n keywords: public, static, private n use of API specification –names: System, out, println –package name: java.lang n the javadoc command: –> javadoc HelloWorld.java –> runJavadoc.bat (in Week01.zip) will organize and document all.java files in a directory
19
The Anatomy of a Java Applet a Java program that runs in a web page subject to security restrictions a Java program that runs in a web page subject to security restrictions Example: HelloWorldApplet.java Example: HelloWorldApplet.java n keyword: import use of API specification - names: java.applet.Applet, paint use of API specification - names: java.applet.Applet, paint n names: packages, classes, method, objects n tools: appletviewer, Firefox
20
IBM i5, iSeries, AS/400 Java Platform n Sun JDK compliant n the QShell Interpreter and Integrated File System (IFS) – simulated UNIX environment n AS/400 Toolbox for Java –Java classes developed by IBM to access OS/400 resources n performance optimization –the JVM is integrated with OS/400 in microcode –OS/400 Java commands: CRTJVAPGM, RUNJVA
21
Java and IBM eServer iSeries n Approach 1: use of a workstation (or desktop) n locally develop Java code, e.g. using IBM WDSC n ftp the Java code to the IBM iSeries server Integrated File System e.g. /bpj444demo n use iSeries QShell (STRQSH) to compile & run: cd /bpj444demo set CLASSPATH. javac HelloWorld2.java java HelloWorld2
22
Java and IBM eServer iSeries n Approach 2: Use of IBM Operations Navigator n workstation development of Java code n “drag and drop” –from Windows Explorer to Operations Navigator –use an iSeries Integrated File System directory n RIGHT click on HelloWorld2.java to compile the code n RIGHT click on HelloWorld2.class to run the code
23
Java and IBM eServer iSeries n Approach 3: green screen server environment n use SEU or EDTF to build Java programs n use CL commands to compile and run Java programs. e.g. ===> RUNJVA CLASS(HelloWorld2) CLASSPATH('/bpj444demo') ===> GO CMDJVA
24
WebSphere Development Studio Client for iSeries n build on Eclipse technology –open source IDE: www.eclipse.org www.eclipse.org n tool for developing Java, etc. code n built-in special support for OS/400 Java - AS/400 Toolbox for Java - Enterprise Toolkit for AS/400 n www.ibm.com/software/ad/wdt400/
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.