1 speak java in one hour an introduction in java lingo

56
1 Speak Java in one hour An introduction in Java lingo

Post on 20-Dec-2015

234 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Speak Java in one hour An introduction in Java lingo

1

Speak Java in one hour

An introduction in Java lingo

Page 2: 1 Speak Java in one hour An introduction in Java lingo

2

Wat is java?

Programmeertaal Jvm Platform

'Write Once, Run Anywhere'

Page 3: 1 Speak Java in one hour An introduction in Java lingo

3

Acronymen hel

Java

Struts

JSFJ2EE

ADFSeam

WebSphere

JSR

Apache

TopLink

Hibernate

JavaFXJDBC

JVM

JavaDoc

Java ME

Java EE

Java SE

NetBeans

Swing

EJBRMI

GlassFish

JMS

JMX

Spring

Maven

ant

NetBeans

Jre

JavaDesktop

Tomcat

Velocity

James Gosling

JPA

JAXB

Trinidad

MyFacesJDK

JavaBeans

JUnit

Drools

RichFaces

WebLogic

JBoss

JSP

Duke

AcegiAOP

Log4J

Applet

JAAS

EL

Servlet

Groovy

Stripes Tapestry

Wicket

Facelets

AWT

GWT

CocoonIceFaces

Java Web Start

iBatis

SDO

Tuscany

TestNg

AMISLucene

JDO

POJO

AjaxJCA

IIOP

JDom

JAXP

JAXB

war

ear

JNDI

SAAJ

JAX-RPC

SCA

JSTL

JIT

JCP

Page 4: 1 Speak Java in one hour An introduction in Java lingo

4

Page 5: 1 Speak Java in one hour An introduction in Java lingo

5

Java language

Object oriëntatie POJO

• Plain Old Java Object• properties• methods

Netwerk support Remoting

Page 6: 1 Speak Java in one hour An introduction in Java lingo

6

Example

import java.net.*;import java.io.*;

public class google {

public static void main (String[] args) { try { String thisLine; URL u = new URL("http://www.google.com"); DataInputStream theHTML = new DataInputStream(u.openStream()); while ((thisLine = theHTML.readLine()) != null) { System.out.println(thisLine); } } catch (MalformedURLException e) { System.err.println(e); } catch (IOException e) { System.err.println(e); } }}

Page 7: 1 Speak Java in one hour An introduction in Java lingo

7

.java .class

jvm

OS

compiler

jit compilation

platform / libraries

bytecode

Page 8: 1 Speak Java in one hour An introduction in Java lingo

8

IDE

Code completion Syntax Highlighting Wizards Documentation Refactoring Unittest support Delivery support Compilation Classpath organization ...

Eclipse WSAD JDeveloper IntelliJ IDEA NetBeans WebLogic Workshop [Notepad] ...

Page 9: 1 Speak Java in one hour An introduction in Java lingo

9

Page 10: 1 Speak Java in one hour An introduction in Java lingo

10

JVM

Platform specific Run bytecode

normally, but not necessary, generated from java source code

The JVM is distributed along with a set of standard class libraries which implement the Java API (Application Programming Interface) : JRE

Page 11: 1 Speak Java in one hour An introduction in Java lingo

11

Page 12: 1 Speak Java in one hour An introduction in Java lingo

12

Java family / Platform

Java SE : Standard Edition Java EE : Enterprise Edition Java ME : MicroEdition Java FX : Scripting & Mobile

Page 13: 1 Speak Java in one hour An introduction in Java lingo

13

Page 14: 1 Speak Java in one hour An introduction in Java lingo

14

History

JDK 1.0 January 23, 1996

JDK 1.1 February 19, 1997

J2SE 1.2 December 8, 1998

J2SE 1.3 May 8, 2000

J2SE 1.4 February 6, 2002

J2SE 5.0 September 30, 2004

Java SE 6 December 11, 2006

Java SE 7 2008

Many version updates

Page 15: 1 Speak Java in one hour An introduction in Java lingo

15

Java SE - Overview

Page 16: 1 Speak Java in one hour An introduction in Java lingo

16

Delivery

jar file java -jar MyApp

Page 17: 1 Speak Java in one hour An introduction in Java lingo

17

Toepassingen

applets Application in browser

GUI apps, Swing Command line Basis voor Java EE Java in the DB Webstart

automatic network distribution

...

Page 18: 1 Speak Java in one hour An introduction in Java lingo

18

Page 19: 1 Speak Java in one hour An introduction in Java lingo

19

History

Page 20: 1 Speak Java in one hour An introduction in Java lingo

20

Toepassingen

Web applications Multitier Distributed Transactional SOA Integration Web Services Messaging ...

Page 21: 1 Speak Java in one hour An introduction in Java lingo

21

Programming

Interfaces Implementation is provided by vendors and

only partially by Java EE (vendor specific) Extensible JavaBeans

Page 22: 1 Speak Java in one hour An introduction in Java lingo

22

Delivery

'Standard' directory structure jar war

/WEB-INF/web.xml

ear /META-INF/application.xml

rar ...

Page 23: 1 Speak Java in one hour An introduction in Java lingo

23

Page 24: 1 Speak Java in one hour An introduction in Java lingo

24

Architecture

Clients

Application Server

EJB Container

EJB

EJBEJB

Web Container

jsp

servlet

OtherSystems

Admin etc.

Page 25: 1 Speak Java in one hour An introduction in Java lingo

25

Architecture

Page 26: 1 Speak Java in one hour An introduction in Java lingo

26

Architecture

Page 27: 1 Speak Java in one hour An introduction in Java lingo

27

Architecture

Page 28: 1 Speak Java in one hour An introduction in Java lingo

28

JOnAS Architecture

Page 29: 1 Speak Java in one hour An introduction in Java lingo

29

WebSphere Architecture

Page 30: 1 Speak Java in one hour An introduction in Java lingo

30

Vendors

Oracle iAS IBM WebSphere BEA WebLogic JBoss GlassFish Geronimo JOnAS SAP Netweaver Pramati ATG Dynamo Tomcat Jetty

http://en.wikipedia.org/wiki/Comparison_of_application_servers#Java

Page 31: 1 Speak Java in one hour An introduction in Java lingo

31

Page 32: 1 Speak Java in one hour An introduction in Java lingo

32

Servlets

Web application Plain java No visual representation

import java.io.*;import javax.servlet.*;import javax.servlet.http.*;

public class HelloWWW extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " + "Transitional//EN\">\n" + "<HTML>\n" + "<HEAD><TITLE>Hello WWW</TITLE></HEAD>\n" + "<BODY>\n" + "<H1>Hello WWW</H1>\n" + "</BODY></HTML>"); }}

Page 33: 1 Speak Java in one hour An introduction in Java lingo

33

JSP

Web application Visual pre-compiled to servlet

Page 34: 1 Speak Java in one hour An introduction in Java lingo

34

Jsp Examples

<%@ page import="hello.NameHandler" %><jsp:useBean id="mybean" scope="page" class="hello.NameHandler" /><jsp:setProperty name="mybean" property="*" /><html><head><title>Hello, User</title></head><body bgcolor="#ffffff" background="background.gif"> <%@ include file="dukebanner.html" %> <table border="0" width="700"> <tr> <td width="150"> &nbsp; </td> <td width="550"> <h1>My name is Duke. What's yours?</h1> </td> </tr> <tr> <td width="150" &nbsp; </td> <td width="550"> <form method="get"> <input type="text" name="username" size="25"> <br> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </form> </td> </tr> </table><% if ( request.getParameter("username") != null ) {%> <%@ include file="response.jsp" %><% }%></body></html>

Page 35: 1 Speak Java in one hour An introduction in Java lingo

35

Jsp with tag Examples

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %><html><head> <title>JSTL: Formatting/I18N Support -- Number, Currency, and Percent

Example</title></head><body bgcolor="#FFFFFF"> <h3>Formatting numbers, currencies, and percentages using <tt>en-US</tt>

locale</h3> <fmt:setLocale value="en-US" /> <ul> <li> Format &quot;123456789&quot; as number:<br>

<fmt:formatNumber value="123456789" /> <li> Format &quot;123456789&quot; as percent:<br>

<fmt:formatNumber type="percent">123456789</fmt:formatNumber> <li> Format &quot;12345.67&quot; as currency:<br>

<fmt:formatNumber value="12345.67" type="currency" /> <li> Format &quot;12345.67&quot; as currency, with special formatting:<br> <fmt:formatNumber value="12345.67" type="currency" groupingUsed="false" maxIntegerDigits="4" maxFractionDigits="0" /> </ul></body></html>

Page 36: 1 Speak Java in one hour An introduction in Java lingo

36

JDBC

import java.sql.*;

public class JdbcExample { public static void main(String[] args) { try { DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@oracle:1521:orcl","scott","tiger"); Statement stmt = conn.createStatement(); ResultSet r = stmt.executeQuery ("SELECT * FROM STD"); while (r.next()) System.out.println(r.getString(2) + " " + r.getString(4)); r.close(); stmt.close(); conn.close(); } catch (Exception e) { e.printStackTrace(System.out); } }}

Java DataBase Connectivity Interactie tussen java en database

Page 37: 1 Speak Java in one hour An introduction in Java lingo

37

EJB

Server-side component architecture Message Driven Beans Session Beans [Entity Beans] [JPA (Java Persistense API)]

Complicated and Complex Improved much with 3.0

Page 38: 1 Speak Java in one hour An introduction in Java lingo

38

Issues

Java (SE / EE) only provides the basics Reference implementation

J2EE is too complicated Long / slow adaptation process for new

technologies

Page 39: 1 Speak Java in one hour An introduction in Java lingo

39

Result

Framework 'hel'

Improvement of Java EJB 3.0

• Convention over configuration

Java Persistence JSF

Page 40: 1 Speak Java in one hour An introduction in Java lingo

40

Page 41: 1 Speak Java in one hour An introduction in Java lingo

41

Struts

Apache Framework de-facto Standard voor jsp development Action based Still alive ADF v9

Page 42: 1 Speak Java in one hour An introduction in Java lingo

42

JSF

Visual Component based Java EE Standard /WEB-INF/faces-config.xml

Page 43: 1 Speak Java in one hour An introduction in Java lingo

43

Available component libraries

ADF Faces JBoss RichFaces IceFaces MyFaces Tobago Trinidad Quipukit WebGalileoFaces ILOG JSF tools Jenia Woodstock ...

Page 44: 1 Speak Java in one hour An introduction in Java lingo

44

Hibernate

Framework voor de interactie tussen java and de database map java objects to db tables query en persist

~ ADF Business Components ~ Toplink

Page 45: 1 Speak Java in one hour An introduction in Java lingo

45

Ontstaan uit onvrede over complexiteit Java EE

Ease of development Non invasive Testability Inversion Of Control / Dependency Injection

Page 46: 1 Speak Java in one hour An introduction in Java lingo

46

Spring Mission Statement

We believe that: J2EE should be easier to use It is best to program to interfaces, rather than classes. Spring

reduces the complexity cost of using interfaces to zero. JavaBeans offer a great way of configuring applications. OO design is more important than any implementation technology,

such as J2EE. Checked exceptions are overused in Java. A framework shouldn't

force you to catch exceptions you're unlikely to be able to recover from.

Testability is essential, and a framework such as Spring should help make your code easier to test.

We aim that: Spring should be a pleasure to use Your application code should not depend on Spring APIs Spring should not compete with good existing solutions, but should

foster integration.

Page 47: 1 Speak Java in one hour An introduction in Java lingo

48

Spring Projects

Spring Framework Spring Web Flow Spring Web Services Spring Security (Acegi Security) Spring Dynamic Modules For OSGi(tm) Service Platforms Spring Batch Spring Integration Spring LDAP Spring IDE Spring Modules Spring JavaConfig Spring Rich Client Spring .NET Spring BeanDoc

Page 48: 1 Speak Java in one hour An introduction in Java lingo

49

ADF

Visual and declarative development of J2EE applications

Onderdelen ADF Faces ADF Business Components ADF Model (binding)

Page 49: 1 Speak Java in one hour An introduction in Java lingo

50

SEAM

JBoss Unify and integrate (o.a)

AJAX, JSF, EJB3, BPM

Page 50: 1 Speak Java in one hour An introduction in Java lingo

51

Page 51: 1 Speak Java in one hour An introduction in Java lingo

52

Open Source

Huge impact on development with Java (EE) Huge influence on Vendor products Major adaptation

Struts, Hibernate, Spring, ... MySQL, Subversion

Donations ADF -> Trinidad

Apache SourceForge CodeHaus

Page 52: 1 Speak Java in one hour An introduction in Java lingo

53

Apache

Commons Utility methods for text, collections, io, en/decoding, http,

etc Struts, JSP MyFaces, JSF Trinidad, JSF Velocity, templating Tuscany, SOA Geronimo, AS Lucene, searching Tomcat, AS Maven, build management Harmony, Open Source Java SE Synapse, ESB ...

Page 53: 1 Speak Java in one hour An introduction in Java lingo

54

Page 54: 1 Speak Java in one hour An introduction in Java lingo

55

Java Community Process

Shapes and organizes the future of Java JSR http://en.wikipedia.org/wiki/Java_Community_Process

Page 55: 1 Speak Java in one hour An introduction in Java lingo

56

The future

Jaca SE 7 - 2008 Java EE 6 - 2008 Java FX Java everywhere Framework shakeout? Better Visual development

Page 56: 1 Speak Java in one hour An introduction in Java lingo

57