Building Java Desktop Apps with JavaFX 8 and Java EE 7

21
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Building Java Applications with JavaFX 8 and Java EE 7 [CON2150] Being a smart Java developer on both client and server-side Bruno Borges Principal Product Manager Java Evangelist Oracle Latin America September, 2014

description

CON2150 presented at JavaOne 2014

Transcript of Building Java Desktop Apps with JavaFX 8 and Java EE 7

Page 1: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Building Java Applications with JavaFX 8 and Java EE 7 [CON2150] Being a smart Java developer on both client and server-side

Bruno Borges Principal Product Manager – Java Evangelist Oracle Latin America September, 2014

Page 2: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Safe Harbor Statement

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Page 3: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Speaker

• Bruno Borges

– Principal Product Manager, Java Evangelist – Oracle Latin America

– @brunoborges – [email protected]

Page 4: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

JavaFX Desktop Applications Today

Exposing Server-side Data with Java EE 7

Java EE 7 APIs for Client-side

Putting all together

Summary

1

2

3

4

5

Page 5: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

JavaFX Desktop Applications

Page 6: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Usual Desktop Architecture

Source: Wikipedia

Page 7: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

JavaFX Frameworks

OpenDolphin

Page 8: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Java EE 7 Not just for Web Development

Page 9: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 10

Java EE 7 APIs

JAX-RS 2.0

JSON-P 1.0 Web Socket 1.0 Servlet 3.1

JSF 2.2 EL 3.0 JSP

JSTL

Bean

Valid

ation 1

.1

Inte

rce

pto

rs 1

.2

CD

I 1.1

Concurr

ency 1

.0

JPA 2.1

JTA 1.2 EJB 3.2 JMS 2.0

Batch 1.0

JCA 1.7

JavaMail 1.5

JAX-WS

JAXB

Page 10: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 11

Java EE 7 APIs for Exposing Data

JAX-RS 2.0

JSON-P 1.0 Web Socket 1.0 Servlet 3.1

JSF 2.2 EL 3.0 JSP

JSTL

Bean

Valid

ation 1

.1

Inte

rce

pto

rs 1

.2

CD

I 1.1

Concurr

ency 1

.0

JPA 2.1

JTA 1.2 EJB 3.2 JMS 2.0

Batch 1.0

JCA 1.7

JavaMail 1.5

JAX-WS

JAXB

Page 11: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

JSR 356: Java API for WebSocket 1.0

@ServerEndpoint("/echo")

public class EchoServer {

@OnMessage

public void onMessage(Session session, String message) {

session.getOpenSessions() .forEach(s ->s.getAsyncRemote().sendText(message));

}

}

Annotated ServerEndpoint Example

Page 12: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

JSR 339 – JAX-RS 2.0

@Path("/chat")

public class ChatServer {

@GET @Produces(“plain/text”)

@Consumes(“plain/text”)

public String echo(String message) {

return “Echoing via REST the message: “+message;

}

...

}

Annotated REST Service

Page 13: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

JSR 372 – JavaServer Faces 2.3

• Build webpages and embed them in JavaFX applications with WebView

• Inject real Java objects by manipulating the DOM tree in WebView

– Do this instead of running Applets in webpages loaded on browsers

– Consider this for applications that require fast layout changes/evolution

• Part of your application is dynamically loaded from Web – Or even the whole screen is loaded as web page?

Page 14: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 15

Java EE 7 APIs for Client-side

JAX-RS 2.0

JSON-P 1.0 Web Socket 1.0 Servlet 3.1

JSF 2.2 EL 3.0 JSP

JSTL

Bean

Valid

ation 1

.1

Inte

rce

pto

rs 1

.2

CD

I 1.1

Concurr

ency 1

.0

JPA 2.1

JTA 1.2 EJB 3.2 JMS 2.0

Batch 1.0

JCA 1.7

JavaMail 1.5

JAX-WS

JAXB

Page 15: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 16

Java EE 7 APIs To Be Used on Client-side

JAX-RS 2.0

JSON-P 1.0 Web Socket 1.0 Servlet 3.1

JSF 2.2 EL 3.0 JSP

JSTL

Bean

Valid

ation 1

.1

Inte

rce

pto

rs 1

.2

CD

I 1.1

Concurr

ency 1

.0

JPA 2.1

JTA 1.2 EJB 3.2 JMS 2.0

Batch 1.0

JCA 1.7

JavaMail 1.5

JAX-WS

JAXB

Page 16: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 17

Java EE 7 APIs You Can Use but Likely Won’t...

JAX-RS 2.0

JSON-P 1.0 Web Socket 1.0 Servlet 3.1

JSF 2.2 EL 3.0 JSP

JSTL

Bean

Valid

ation 1

.1

Inte

rce

pto

rs 1

.2

CD

I 1.1

Concurr

ency 1

.0

JPA 2.1

JTA 1.2 EJB 3.2 JMS 2.0

Batch 1.0

JCA 1.7

JavaMail 1.5

JAX-WS

JAXB

Page 17: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 18

Hybrid JavaFX Desktop Application – Architecture

Windows Mac OS X Linux

Oracle JRE

JavaFX

Application

Embedded Browser

Native UI Controls

Native Hardware

Access

An HTML5 (remote/local) application

Native Controls in JavaFX with Themes and CSS Styles

Java libraries for hardware integration

Bundle the JRE with your application for native

installers

One unified desktop

application

Page 18: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

JavaFX Hybrid Apps Building Desktop Apps instead of Web Apps with Applets

Web Browser

Your Web Page * that requires applets

Applets

JavaFX Desktop “Hybrid” Application

Embedded Browser – JavaFX’s WebView

Native Features

Page 19: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Demo

Page 20: Building Java Desktop Apps with JavaFX 8 and Java EE 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Adopt-A-JSR

• Want Java EE APIs to be aligned with Desktop/JavaFX Applications?

• Want a Java EE “Client Profile”?

Oracle Confidential – Internal/Restricted/Highly

23

glassfish.org/adoptajsr

Page 21: Building Java Desktop Apps with JavaFX 8 and Java EE 7