Beruflich Dokumente
Kultur Dokumente
●
Carol McDonald
–JavaArchitect
●Sun Microsystems
1
Java SE Platform Roadmap and
Themes Multiple Languages
Modularity
Rich Clients
Java SE 6 Java SE 7
Announce JavaFX
JavaFX SDK
JRE 6u10
'Consumer JRE'
Open Sourcing OpenJDK™
Java Launch JRE 6u5p
'It’s not a matter of 'Performance JRE'
when but how'
2
Agenda
Java SE Technology Today
Dynamic Language Integration
Web Services Enhancement
Database Update
Desktop Improvement
Java SE 6 Update 10
New Developments in the Platform
Multiple Languages
Modularity
Management and VisualVM
Rich Clients
3
Project OpenJDK
Open Source Java SE Platform Implementation
●
OpenJDK is an open source project that implements Java SE 6
(and beyond) platform
●
Majority of the code released under GPLv2
• OpenJDK community
> openjdk.java.net
4
How Java SE Platform Gets
Developed
Present and future
5
JDK™ version 6 – Filling in the distribution gaps
• OpenJDK-based Java SE 6
+ bundled in Ubuntu 8.04
TS-5214
OpenJDK Community Update
Wed 2.50pm
6
Java SE 6 Platform: Top 10 Features
7
Java SE 6 : Top 10 Features
10
Languages on the JVM™: Present Sleep
12
Scripting
• Scripting for the Java Platform (JSR 223)
> Framework APIs for adding script engines
> Access to resources of the Java platform, JAR files, from
scripting languages
> Developer APIs to mix script fragments with Java
language code
> Access to scripting languages from Java
• A JavaScript engine is included in JDK 6
> Mozilla Rhino engine
• other JSR 223 compliant scripting engines (Groovy,
Ruby, Python, et al) can be downloaded from
> scripting.dev.java.net
13
Launch Script within Java Code
// create a ScriptEngineManager
ScriptEngineManager m = new ScriptEngineManager();
// evaluate a script
engine.eval("alert(\"Hello World!\")");
14
Bind Java Objects to script
// create script engine manager
ScriptEngineManager manager = new ScriptEngineManager();
15
Scripting on Java SE 6 Platform
// create a ScriptEngineManager & grab an engine
ScriptEngineManager m = new ScriptEngineManager();
ScriptEngine engine = m.getEngineByName("js");
16
Demo: Scripting with Java SE
• Build and run ScriptPad sample app from JDK 6
samples
> You can build and run as NetBeans project
• Executing JavaScript code
• Invoking Java methods from JavaScript code
17
Web Services
XML and Web Services
• JAX-WS is part of Java SE 6 platform
> Interoperability: Standards
> SOAP 1.2
> WS-I Basic Profile 1.1
• Data binding using JAXB 2.0
> XML <=> Java Object
• Updates to the JAXP, which includes StaX
> Xml parsing “Pull model”
19
Web Service – Example
// Create a POJO
20
Web Service – Example
// Create a service implementation
@WebService
public class Calculator {
public int add(int a, int b) {
return a+b;
}
}
21
Web Service Development
• Tools to generate necessary files for you
> wsgen: generates service stubs on the service side
e.g.
wsgen -cp . example.Stock -wsdl -servicename
{http://mynamespace}MyService
> wsimport: generates proxy stub on the client side
e.g.
wsimport -d generated http://example.org/stock?wsdl
22
Web Service Client
23
Database
Java DB
• Java DB database bundled with JDK 6
> Java DB is based on Apache Derby
• open source Apache Derby 100% Java database
• Ideal for embedded or client-server use.
> Small -- 2MB.
> Embed in browser for better Web 2.0.
> Easy application + DB distribution.
25
JDBC 4.0 SQL XML support
• SQLXML Data Type:
SQLXML sqlxml = resultSet.getSQLXML(column);
InputStream binaryStream = sqlxml.getBinaryStream();
Document result = parser.parse(binaryStream);
• Support for WebRowSet
> Extends CachedRowSet + Rows in XML
ResultSet rs = stmt.executeQuery("select * from student");
WebRowSet wrs = new WebRowSetImpl();
wrs.populate(rs);
wrs.writeXml(new FileOutputStream("student.xml"));
26
JDBC 4.0 Annotation-Based SQL
Queries
public class Person {
public String id;
public String firstName, String lastName;
public String deptCode;
}
27
Desktop APIs
Improvements
Desktop APIs Improvements
• AWT improvements
> Tray icon
> Splash screen
> Desktop class
> Dialog modality enhancements and API
> Text printing
• Swing improvements
> GroupLayout – basis for NetBeans GUI Builder
(Matisse)
> JTable sorting and filtering
> SwingWorker
29
Tray Icon Support
• Tooltip and Image
• Popup menu
> Actions, events respond to clicks
// Construct a TrayIcon
TrayIcon trayIcon = new TrayIcon(image, "Tray Demo",
popupMenu);
30
Splash Screen Support
31
Java Desktop integration
• java.awt.Desktop API
> Launch the default browser
> Launch the default email client
> Launch the default application to handle file open, file edit
and file print
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Desktop.Action.EDIT))
{ desktop.edit(file }
desktop.browse(url);
32
SwingWorker
For Easy Multi-threaded Application Development
With Swing
• Makes use of concurrency package
• Makes it easy to offload work to separate threads
• Example :
> http://java.sun.com/developer/technicalArticles/javase/swingworker
• More Information:
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html#SwingWorker
33
SwingWorker – Example
class ImageRetriever extends SwingWorker<Icon, Void> {
@Override
public String doInBackground() {
Icon icon = retrieveImage(strImageUrl);
return icon;
}
@Override
protected void done() {
lblImage.setIcon(icon);
..
}
}
// in event handler tell thread to begin asynchronous method.
ImageRetriever imgRetriever =
new ImageRetriever(lblImage, imageUrl);
imgRetriever.execute();
// This event thread continues here without blocking.
34
Monitoring &
Management
jconsole, jps, jmap, jhat, jstack
• Run a sample Java application
• Use the tools
> Use jps to see process ids of all Java processes
> Use jconsole to dynamically connect to a process
> Use jmap to capture snapshot of memory heap of a Java
process
> Use jhat to interpret heap
> Use jstack to thread-dump on a live process
• You can try this
> www.javapassion.com/handsonlabs/javase6tools/
36
Compiler Access
Compiler Access
38
Pluggable Annotations
Pluggable Annotations
40
Security
Security
42
Java SE 6 Update 10
Java SE 6u10 “Consumer JRE”
44
Java SE 6u10 “Consumer JRE”
• Quickstarter
> Reduces the start up time for Java applications and applets
• Java Kernel
> divides JRE libraries into small bundles. Only download whats
needed now, rest later
• Deployment Toolkit
> Enables easy detection and installation of the JRE
• New Improved Java Plug-In
• Nimbus:cross-platform Swing look & feel
45
Old Java Plugin Architecture
46
New Java Plugin Architecture
• Applets have own process
> Choose the VM they want
> Live outside browser
> Live beyond the browser
> Same deployment as Java
Applications
JVM
in
Browser
Applet Applet
JVM
Applet
JVM
47
Nimbus Look and Feel Improvements
SwingSet
48
Performance
Java SE 6u5p “Performance Release”
180%
170%
160%
150%
140%
130%
120%
110%
100%
J2SE J2SE J2SE J2SE Java SE 6.0 Java SE Java SE Java SE
5.0_04 5.0_05 5.0_06 5.0_08 6.0_02 6.0_05 6.0_05-P
51
Java Platform Performance Trends on x64
SPECjbb2005 onIntel and AMD
280%
260%
240%
% Perf. Improvement
220%
200%
Intel Core 2
180% AMD Barcelona
160%
140%
120%
100%
J2SE J2SE J2SE J2SE Java SE 6.0 Java SE Java SE Java SE
5.0_04 5.0_05 5.0_06 5.0_08 6.0_02 6.0_05 6.0_05-P
52
Java SE 7 Highlights:
Scripting
Languages on the JVM™: Present
Sleep
57
Java Module System
Classloaders
• Address "JAR hell"
• Better distribution format than JAR files
• Enable side-by-side versioning Versioning
• Simple and predictable classloading
59
Modules in the Java language
// org/netbeans/core/Debugger.java
module org.netbeans.core;
Module concept
package org.netbeans.core;
in the language
public class Debugger {
... new ErrorTracker() ...
}
60
Modules in the Java language
// org/netbeans/core/Debugger.java
module org.netbeans.core;
Module concept package org.netbeans.core;
in the language public class Debugger {
... new ErrorTracker() ...
One module }
has many
packages // org/netbeans/core/utils/ErrorTracker.java
module org.netbeans.core;
package org.netbeans.core.utils;
Module access
specified in the module class ErrorTracker {
language module int getErrorLine() { ... }
}
61
The JAM Module System
• Java Modules
> JAR-like file format
> Easy metadata
> Addresses problems with JARs
62
JAM metadata
Version // org/netbeans/core/module-info.java
@Version("7.0")
Main class @MainClass("org.netbeans.core.Main")
@Attribute(name="IDE", value="NetBeans")
Attributes
Module @ImportModules{
dependencies @ImportModule(name="java.se.core",
version="1.7+"),
Custom import @ImportModule(name="org.foo.util",
policy
version="1.0", reexport=true)
})
Initializer
@ImportPolicyClass("org.netbeans.CustomPolicy")
Platform @ModuleInitializerClass("org.netbeans.core.Init")
specific
@PlatformBinding(os="solaris", arch="sparc")
Exported
@ExportResources({"icons/**"})
resources
module org.netbeans.core;
63
Compiling and running a JAM module
• javac org/netbeans/core/*
• javac org/netbeans/core/utils/*
• cp org.netbeans.core-7.0.jam /netbeans/repository
• java -module org.netbeans.core:6.0+
-repository /netbeans/repository
64
org.netbeans.core-7.0.jam
66
Loading OSGi bundles in JDK version 7
JVM
Bootstrap repository
OSGi Interoperability
Extension repository
OSGi bundles
67
Java Module System - Status
68
Modularizing Java SE itself
69
The (full) Java SE Platform
Java SE Applications
Web
Enterprise Core
Services / GUI
APIs APIs
data access
Tools
APIs
JVM
OS
70
Java SE Rich Client Profile
Rich Client
Applications
Enterprise
APIs
Web
Core
Services / GUI
APIs
data access
Tools
APIs
JVM
OS
71
Management Updates
• JSR 255: Java Management Extensions (JMX™) Specification,
version 2.0
> Federated JMX technology servers
> Get code: opendmk.dev.java.net
72
Management Updates
• Web Services Connector for JMX Agents
> early access Get code: ws-jmx-connector.dev.java.net
• Based on web service management standards
> WS-Management (DMTF)
> http://www.dmtf.org/standards/wsman/
WS-Management Request
Client JSR 262 Server
Request MBean Server
Response
WS-Management Response
73
VisualVM for Sun's JDK
• Get the release candidate today BOF-5223
VisualVM
> visualvm.dev.java.net Thu 7.30pm
James Gosling
Extreme Innovation
Fri 8.30AM
74
What's VisualVM?
A new Integrated and Extensible Troubleshooting
Tool for the Java Platform
JDK Management, Monitoring and Troubleshooting
tools and lightweight CPU and Memory profiling
Production and development time tool
Audience: developers, administrators, performance
and sustaining engineers, etc.
https://visualvm.dev.java.net
75
Closure
• anonymous function, for cross cutting concerns
• Closure literals
{ parameters => statements expression }
{ int x, int y => (x + y) }
• Function example
int answer = { int x, int y =>
(x + y) }.invoke(5, 7);
• Evolving specification at
> http://www.javac.info
76
Closure Conversion Example
ActionListener
listener
=
{
ActionEvent
evt
=>
saveAll();
};
JButton
button
=
new
JButton(“OK”);
button.addActionListener(listener);
77
Important Updates
• More New I/O APIs
> New filesystem API
TS-5686
> Revised socket channel functionality New I/O APIs
Thu 9.30am
> Asynchronous I/O
• Draft stage
> openjdk.java.net/projects/nio/
> Spec, code, samples
78
Call For Action
• Java SE 6 platform
> Use it now!
• OpenJDK
> Join us in building it!
• Java SE 7 platform
> Join us in defining it!
• Interact with JDK developers @ planetjdk.org
79
Java SE 6 and 7 Features
●
Carol McDonald
–JavaArchitect
●Sun Microsystems
80