24
1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical Sciences 2 Agenda Summary of Previous Sessions Java Platform Architectures, and Files Java Virtual Machine Traditional Java Tools Java Project Management Approach Readings Class Project & Assignment #1b

g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

1

1

Extreme JavaG22.3033-007

Session 2 - Main ThemeJava Tools and Software Engineering Techniques

Dr. Jean-Claude Franchitti

New York UniversityComputer Science Department

Courant Institute of Mathematical Sciences

2

Agenda

Summary of Previous SessionsJava Platform Architectures, and FilesJava Virtual MachineTraditional Java ToolsJava Project Management ApproachReadingsClass Project & Assignment #1b

Page 2: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

2

3

Announcements

Student accounts on i5.nyu.eduExtreme Java and eXtreme Programming (XP)Homeworks & Projects due datesGrader assignmentsJava IDEsJ2EE-Compliant Application ServersAssignment #2

4

Summary of Previous Sessions

Review Java’s Programming Language FeaturesCourse Logistics, Structure and ObjectivesEnterprise Software FoundationsApplication Performance EnhancementsLimitations of the Java EnvironmentClass Project & Assignment #1a & 1b

Page 3: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

3

5

Part I

Java Platform and Architecture

6

Key Platform Features

ResourcesPackagingToolsEnvironmentOpen Source Solutions on the Java Platform:

http://jakarta.apache.org/

e.g., “regexp” regular expression package, “log4j”logging package, etc.

Page 4: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

4

7

Java Platforms Architectures, and FilesRuntime Environment Architecture

Byte code verifierClass loaderRuntime Execution Engine / optimizerSecurity Manager (java.lang.SecurityManager) and API class files

JVM enables type-safe reference casting, structured memory access (no pointerarithmetic), automatic garbage collection (can't explicitly free allocated memory),array bounds checking, checking references for null

Native platform interface libraries

File TypesSource code files (see http://java.sun.com/docs/codeconv/index.html)Class filesSerialization filesArchive filesManifest files

8

Part II

Java Virtual Machine

Page 5: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

5

9

Java Virtual Machine (JVM)Write Once Run Anywhere (WORA) Architecture

10

Java Virtual Machine (JVM)(continued)

Byte Code VerifierClass Loader (dynamic operation)Runtime Execution Engine

Performance bottlenecks:Byte Code Execution, garbage collection, thread management,dynamic operations (i.e., class loading, bounds checking, securitymeasures, dynamic class loading, exception handling, reflection,and native method translation)

Just-in-time compilerReduces byte-code interpretation and causes the executionworkload to shift to native compilation and caching of nativemethods.

Precompiler

Page 6: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

6

11

Pre Java 2 Security

12

Java 2 Security

Page 7: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

7

13

Java 2 Security

14

Part III

Java Tools

Page 8: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

8

15

Traditional Java Tools

javacjarjavajavadocjdbappletviewer

16

Java Interpreter

Software that implements the JVM and runsJava applicationsStandalone or part of larger application(e.g., browser)Likely written in a native, compiledlanguageLoads Java class files and interprets thecompiled byte-code

Page 9: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

9

17

Java Interpreter(continued)

Verifies compiled classes loaded fromuntrusted sourcesCan turn Java byte-code into nativemachine instructions (dynamic/JITcompilation)java [interpreter options] class name[program arguments]

18

Using “java”

Class should be fully qualified class name(including class package if any)Shouldn’t include “.class” file extensionSearches for the class in current class path(-classpath option)

Page 10: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

10

19

Using “java”(continued)

Looks for main() methodmain method signature: public static void main( String [ ] myArgs )myArgs[0] is the first command line argumentNo need for argument count parameter (int argc= myArgs.length)

20

Class Path

Piece of environment information providinga list of places to look for some resourcesCLASSPATH: list of locations that can besearched for packages containing Java classfilesUsed by Java interpreter and compiler

Page 11: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

11

21

Class Path(continued)

CLASSPATH includes directory names orthe names of class archive files (.zip or .jar)Use colon separator (UNIX), or semicolonseparator (DOS/Windows)Default paths:

.:$JDK_HOME/classes:$JDK_HOME/lib/classes.zip (UNIX).;%JDK_HOME%\classes;$%JDK_HOME%\lib\classes.zip (Windows systems)

22

Java Compiler

Turns Java source code into a compiledclass containing JVM byte-code.java -> .classAllows one public class per file (file hassame name as class)Storing the class files in alternate directory:use -d option

Page 12: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

12

23

Part IV

Java Applications

24

Type of Java Applications

Standalone Java applicationRuns independently

Applet (embeddable program module)Part of a larger applicationCompatible with mainstream browsers(Netscape, IE), and the Java appletviewer

JWS (Java Web Start) ApplicationsA component model for deployable clientsoftwareSubsumes the Applet component model

Page 13: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

13

25

Java Web Start (JWS) Technology

See http://java.sun.com/products/javawebstart/Applications do not require a browser oncedownloadedFiles are cached on the clientChecks are performed with the web server to ensurethat the latest version of the application is being used(ZAC!)Built on top of Java 2 SecurityLinks point to JNLP files which syntax is defined aspart of a Java Community Process specification

http://java.sun.com/aboutJava/communityprocess/jsr/jsr_056_jnlp.html

26

JWS Application Launching

Page 14: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

14

27

Sample JNLP File<?xml version="1.0" encoding="utf-8"?><jnlp

spec="1.0+"codebase="http://javaweb.eng.com/jaws/apps" href="swingset2.jnlp"><information>

<title>SwingSet2 Demo Application</title><vendor>Sun Microsystems, Inc.</vendor><homepage href="docs/help.html"/><description>SwingSet2 Demo App</description><description kind="short">A demo</description><icon href="images/swingset2.jpg"/><offline-allowed/>

</information><security>

<all-permissions/></security><resources>

<j2se version="1.3"/><jar href="lib/SwingSet2.jar"/>

</resources><application-desc main-class="SwingSet2"/>

</jnlp>

28

JNLP Element to Launch an Applet

<applet-descdocumentBase="http://..."name="TimePilot"main-class="TimePilot.TimePilotApp"width="527"height="428"><param name="key1" value="value1"/><param name="key2" value="value2"/>

</applet-desc>

Page 15: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

15

29

JNLP API

BasicServiceClipboardServiceDownloadServiceFileOpenServiceFileSaveServicePrintServicePersistenceService

30

Applet Tag

<applet attribute [attribute] …>[<param parameter>][<param parameter>]…[HTML for non Java aware browsers]</applet>

Page 16: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

16

31

Applet Tag(continued)

attributes: width, height, code / object(serialized representation of applet)parameter: <param name=zonevalue=GMT>

32

Applet Plug-InNeeded for RSA signed applet verificationProvides enhanced applet debugging andmanagement featuresDownload JDK 1.3.1_01 which includes thelatest version of the Java Plug-in 1.3software

http://java.sun.com/products/plugin/

Consult the Java Plug-in documentationhttp://java.sun.com/products/plugin/1.3/docs/index.docs.htmlhttp://java.sun.com/products/plugin/1.3/docs/quick_start.html

Download the HTML converter 1.3.0_01http://java.sun.com/products/plugin/1.3/converter.html

Page 17: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

17

33

Java 2 Plugin Architecture(http://java.sun.com/j2se/1.3/jre/)

34

Open JVM Interface (OJI)

Allows any Sun-Compliant JVM(implementing OJI) to become the defaultJVM for a browserSupports Applet, Embed, and Object tagsSupports Java-JavaScript bidirectionalcommunicationSupports RSA signed applet verification

Page 18: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

18

35

Applet SecurityJava Plug-In Security Reference

http://java.sun.com/j2se/1.3/docs/guide/security/index.html

Security FeaturesRSA signed applet (jar signing in the JDK)HTTPS (handled via browser)Liveconnect for Java-JavaScript bidirectionalcommunication

Origin of HTML page must be same as that of appletJavaScript must be signed and “UniversalBrowserRead”permission must be enabled for JavaScript (default is localJava policy)http://java.sun.com/products/plugin/1.3/docs/jsobject.htmlz

36

Java 2 Security

Page 19: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

19

37

Java 2 Security(secure application distribution using Java cryptography API)

Secure Application DistributionApplications stored as a self-executing encrypted fileOnly class file data is encryptedMain executable file must be distinguishable

Four PhasesPackagingEncryption/DecryptionLoadingExecution

38

Part V

Packaging Java Applications

Also See Session 6 Handout on:

“How to Submit Projects in Zip or Jar Files”

Page 20: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

20

39

Packaging: Java Archive (JAR) Files

Can compress with ZLIB compressionCan use pkzip to create and maintain JARfiles“jar” is the java archive utilityJAR file advantages: compression andaccess time

40

JAR Utility

See handout on how to submit projectsusing zip/jarjar -cvf jarFile path [path] […]jar -tvf jarFile [path] […]jar -xvf jarFile [path] […]Alternatives: Mobile Object and AgentsGUI Jar utility (MOAJar), etc.

Page 21: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

21

41

JAR Utility (continued)

jar adds META-INF/MANIFEST.MFpacking list naming files along withcryptographic checksumsjar -cvmf myManifest.mf spaceblaster.jarspaceblaster

Use javakey to sign a JAR file (see digitalsignature / certificate)

42

Java 2 Security(secure application distribution using Java cryptography API)

Secure Application DistributionApplications stored as a self-executing encrypted fileOnly class file data is encryptedMain executable file must be distinguishable

Four PhasesPackagingEncryption/DecryptionLoadingExecution

Page 22: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

22

43

Part VI

Java Project Management

Also See Session 6 Sub-Topic 1 Presentation on:

“Java Project Management”

44

Java Project Management ApproachRefer to the links on eXtreme Programming (seeunder “Announcements” on the course web site)See “Java Tools for Extreme Programming:Mastering Open Source Tools, including Ant, Junit,and Cactus” (Richard Hightower, Nicholas Lesiecki,ISBN: 0-471-20708-X, 11/2001)

Regression testing framework: http://www.junit.org/Ant build tool, and Cactus server-side unit testing:http://www.apache.org/

See the Sub-Topic presentation on Java ProjectManagement

Page 23: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

23

45

eXtreme Programming (XP) Maphttp://www.extremeprogramming.org

46

XP Iteration Planninghttp://www.extremeprogramming.org

Page 24: g22 3033 007 c21...1 1 Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science

24

47

XP Unit Testinghttp://www.extremeprogramming.org

48

Assignment

ReadingsBuilding Java Enterprise Systems: Part I (4)Slides and handouts posted on the course web site

Assignment #1b:MetaJava VM installation/explorationRead Papers on Behavioral Reflection

Project Framework Setup (see homework #2 spec.)Java-Based “Thick-Client” 2D chat environmentJ2SE/J2EE SDKs, IDE, Java Plug-in, JWS, Apache’sXerces/XalanInstall/experiment with project reusable S/W components