Wednesday Sep 25, 2013

Session Report: Demystifying Java EE

Adam Bien, who is not only a Java Champion and JavaOne Rock Star, but was named in 2010 as Oracle Magazine’s Java Developer of the Year, spoke to an enthusiastic crowd where he addressed some core issues about Java EE. He encouraged questions – “The more heretical or offensive the better.” It was obvious that Bien loves to think about and code in Java. He remarked, “The more I code the happier I am”. Spoken like a hard-core Java developer!

First, he asked, “What is Java EE? Innovation vs. Standardization”?  For Bien, Java EE is nothing but a release of co-existing APIs. Before Java EE, there was a mess with lots of application servers, with absolutely no chance of finding two application servers with similar APIs. Java EE resulted in a huge simplification. Now with Java EE 7 a wealth of are applications available. Java EE, insisted Bien, was never about innovation because building a standard precludes innovation. “Java EE will always lag behind,” he observed. “For instance, Hibernate will always have more features than JPA. Spring will always have more features than CDI. Java EE is the 80% that makes products work. It was never about innovation.”

He boiled down the whole point of Java EE: “What matters are small WARs – the smaller the WAR, the faster the build and deployment. The faster the build and deployment, the more productive you become,” he insisted. He explained that Java EE enables you to not put everything into the WAR and place as much as possible on the application server and less on the WAR. He explained that most of his WARs in Java EE 6 or Java EE 7 projects are very small

Bien asked, “Are EJBs bloated?” He explained that the question implies some voodoo stuff behind the scenes making EJBs bloated. He offered a means to answer this question.

He went on to answer a wealth of questions in a way that was thoughtful, incisive, witty and, at times, a bit provocative.

Here's some of the topics/issues (pulled directly from his slides) that Adam touched on in this fast-paced session:

*Do we need transactions?
*Is Dependency Injection Black Magic, VooDoo, or both?
*Is EJB pooling needed? Are EJBs bloated? What happens, if you violate the EJB programming restrictions?
*Why AOP didn't take off in Java EE?
*Stateless vs. Stateful programming model?
*HA without a Cluster?
*Are there any POJOs out there? What happens during deployment?
*Is Java EE faster than J2EE? Does JMS 2.0 scale and perform well? Is Java EE only suitable for the "big" enterprise?
*Is JSF the silver bullet? What is the deal with CORBA and RMI?
*How to unit test Java EE applications? Why we don't build a best of breed server from scratch?

This was a lively, entertaining and information-packed session. Just what you would expect from a pro developer as Adam Bien. I highly recommend viewing this session.

Adam Bien’s Blog
Check out Parleys.com where you can listen to the session in early October.

Monday Sep 23, 2013

The JavaOne 2013 Technical Keynote

by Timothy Beneke

Mark Reinhold, Oracle’s Chief Architect, the Java Platform Group, took the stage to kick off Sunday’s technical keynote at the Moscone Center. He began by quoting “father of Java” James Gosling. For Java to thrive, it must maintain what Gosling called the “feel of Java”. In other words, it must retain the key values of readability, simplicity, and universality.

“If we keep those,” said Reinhold, “then Java will remain not just productive but fun. It is not enough to simply add popular features each year.”

Lambda Expressions – The Single Largest Upgrade Ever
He turned to lambda expressions, which he described as the single largest upgrade to the programming model ever -- larger even than generics. “This is the first time we have done a carefully coordinated co-evolution of the JVM, the language, and the libraries all together – and the results still feel like Java,” said Reinhold.

He then welcomed Oracle Java Language Architect, Brian Goetz, to share the stage and began by remarking that while most developers understand that lambda offers a simple way to express code as data, some are not sure how it helps Java. Goetz responded that lambda expressions would more than help Java. “It’s going to change the way we all program in Java every day,” he explained. “Programming well is about finding the right abstractions. We want the code we write to look like the problem statements it’s trying to solve, so we can look at it and immediately know it’s correct. Java has always given us good tools for abstracting over data types. I wanted to do better in abstracting over patterns of behavior – that’s where lambda comes in.”

He illustrated this with some simple code that was, strictly speaking, “good” code, but weighed down with boilerplate and did not read like the problem statement it was trying to solve. It could be improved by using an inner class tool, but that too generated a lot of boilerplate. Reinhardt pointed out that improving the code made it less pleasant to work with, as if the developer was being punished for doing the right thing. This often causes developers to give up and do it the “dumb and ugly way”.

Lambdas can replace inner classes with a lambda expression which is simply an anonymous method that captures a behavior without a lot of syntactic boilerplate. “Lambdas are a nicer syntax,” said Goetz. “But they are also something deeper. It’s not just a compiler generating inner classes for you – it uses the invokedynamic feature to get more compact and higher performance code. It will make a qualitative difference in the way we program.”

If the right way to write a program is unpleasant, then people are less likely to do it according to Goetz. They are more tolerant of doing it the wrong way. He gave an example of how lambda expressions address this with the collections API involving a new abstraction to the JDK called stream and showed how to represent a simple query through applying a filter and mapping transformation, followed by an aggregation, in a way that is fused into one path without creating any intermediate weapons.

Reinhold summarized the key points: “So lambda brings 3 weapons to Java – syntax, performance and abstraction.”

“Plus parallelism,” Goetz added. He explained that Java 7 has the fork/join framework for parallel decomposition that is powerful, flexible, and highly efficient – but not the easiest thing to use. Goetz showed how lambdas enable better parallelism without needing to write fork join code: by asking the collection for a parallel stream it uses fork/join under the hood.

Lambda also helps with normal sequential code by making code clearer, less noisy, and easier to read. “When you have code that is hard to read, that’s where bugs come from. You are trying to maintain some code, you look at the code and think you know what it does, but don’t actually know what it does, and boom! – you’ve introduced a bug.”

All in all, the message was clear: Lambda expressions make Java code easier to read and easier to write.

Working with Lambda and the Collections Framework
For lambdas to be successful, they must work with the Java Collections Framework, which is now 15 years old. So an evolution of the interface was in order. Goetz’s team had to grow an interface over time without breaking implementations of the interface. They added a concept that allows developers to compatibly add a method to an interface, as long as a default implementation is provided.

Reinhold remarked that he has now written a couple of thousand lines of code with lambda features and really enjoyed it. “I can be more productive, and the end result still feels like Java,” he said.

To get started learning lambda expressions, Java developers can go to the OpenJDK Project Lambda page and download the developer preview builds there.

Reinhold reminded attendees that there is a great deal more in Java SE 8 besides lambda expressions. Developer preview builds can be downloaded at JDK8.java.net. “Now is a great time to download JDK 8 and take it for a spin. Every planned feature is in there. It’s reasonably stable and it passes almost all of the tests. If you have any feedback, please send it in!” said Reinhold. 

Playing Chess
In the rest of the technical keynote, Oracle’s John Ceccarelli, head of engineering for Oracle’s NetBeans team and Oracle’s JavaFX architect Jasper Potts, arrived on stage to demonstrate a Duke pad running real Java via a chess program that was connected to a server. The iPad operated through an HTML5 client talking to a Java EE 7 back end with an EE server in charge of  messaging, communication, game state, and so on, with clients hook into it – all built with NetBeans. Jasper Potts further showed off the chess demo with an HTML5 client using a front end to a chess server that was managing the chess games. Then a robot, powered by Java ME 8, took over the game.

Oracle Software Engineer, Santiago Pericas Geertsen, who built the chess server, also described how it was built with 5 distinct functional modules.

In sum, attendees witnessed a server running Java EE 7 hooked up with a variety of clients, some written in HTML5, one written in JavaFX on a Duke pad, one using JavaFX 3D on a powerful laptop, plus a Java ME 8-powered robot contributing to the ongoing chess game. In the process, the powers of the Raspberry Pi were demonstrated.

Developers were encouraged to jump in the water, go for a swim, and have fun with NetBeans and Java embedded.

Java SE 9 and Beyond
Wrapping it up, Reinhold peered a bit into the future and suggested some possible directions for Java, some of which are already in development:

One is Java on GPUs, graphic processing units. As GPUs are being used more and more widely to process big data he suggested that it would be good to make Java work directly with the GPU rather than having to call out to some primitive interface. An OpenJDK called Sumatra has people working on this.

Reinhold spoke of the need for reification. Java’s generics, added in 2004, are based on the notion of erasure for good technical reasons as a sound way to create a type system that supports migration compatibility. But this creates programming problems in which the erasure approach severely limits what can be expressed. Reinhold suggested that introducing some reification and eliminating the “annoying dichotomy between primitive and reference types” would be of value.

He mentioned JNI 2.0 and said, “It just shouldn’t be so hard to integrate Java with native code after all these years.”

He called for memory efficient data structures: “As we get into big data – all this boxing and pointer chasing makes it hard to do big data well. We could have less boxing and pointer chasing and load a lot more data into memory.”

Finally, he talked about the notion of a truly modular platform. “The compact profile in Java 8 is a start but it is not flexible enough. We need to continue to unify the Java SE and Java ME platforms.”

JDK 8

OpenJDK Project Lambda

Watch Keynote and Session Highlights on Demand

Friday Jul 19, 2013

Java API for JSON Processing: An Introduction to JSON

A new article, now up on otn/java, by Oracle’s Jitandra Kotamraju, titled “Java API for JSON Processing: An Introduction to JSON,” takes a look at how Java API for JSON Processing provides portable APIs to parse, generate, transform and query JSON, also known as JavaScript Object Notation. Kotamraju, a principal member of the technical staff at Oracle, is the JSON Processing specification lead.

JSO, a lightweight, text-based, language-independent data exchange format that is easy to read and write by both humans and machines, can represent two structured types: objects and arrays. Kotamraju, the JSON Processing specification lead, explains that “an object is an unordered collection of zero or more name/value pairs. An array is an ordered sequence of zero or more values. The values can be strings, numbers, booleans, null and these two structured types.”

JSON is frequently used in Ajax applications, configurations, databases, and RESTful web services. JSON is offered as the data exchange format with their RESTful web services by all popular websites.

Kotamraju gets under the hood with both the object model and streaming APIs. He concludes that the API for JSON Processing offers the following capabilities:
* “Parsing input streams into immutable objects or event streams
* Writing event streams or immutable objects to output streams
* Programmatically navigating immutable objects
* Programmatically building immutable objects with builders”

The API forms a base for building data binding, transformation, querying, or other manipulation APIs. JAX-RS 2.0 provides native integration for the Java API for JSON Processing.

Check out the article here.

Friday Jun 07, 2013

New Messaging Features in JMS 2.0

Part Two of Nigel Deakin’s series on JMS 2.0 (Java Message Service), titled “What's New in JMS 2.0, Part Two—New Messaging Features,” is now up on otn/java. While Part One looked at new ease-of-use features introduced in JMS 2.0, Part Two explores five important new messaging features.

First, a new kind of topic subscription called a shared subscription now allows for multiple consumers on the same topic subscription.

Second, developers can now specify a delivery delay on a message so that the JMS provider will not deliver the message until after the specified delivery delay has elapsed

Third, with JMS 2.0, users can send a message asynchronously. As Deakin explains, “This feature is available for applications running in Java SE or the Java EE application client container. It is not available to applications that run in the Java EE Web or EJB container.” According to Deakin, “When a message is sent asynchronously, the send method sends the message to the server and then returns control to the application without waiting for a reply from the server. Instead of being blocked unproductively while the JMS client waits for a reply, the application can do something useful, such as sending a further message or performing some processing.”

Deakin explains that there are two main ways in which you might use an asynchronous send in an application:

* To allow the application to do something else (such as update the display or write to a database) during the interval when it would otherwise be waiting for a reply from the server

* To allow a large number of messages to be sent in succession without waiting for a reply from the server after each message

Fourth, JMS 2.0 allows applications that receive a message to determine how many times the message has been redelivered.

And finally, a Java EE application that needs to receive messages asynchronously does so using an MDB, or message-driven bean, which is configured by specifying a number of configuration properties. Check out the article here.

Wednesday May 22, 2013

What's New in JMS 2.0: Ease of Use

A new article by Oracle’s Nigel Deakin, up on otn/java, titled “What's New in JMS 2.0, Part One: Ease of Use,” demonstrates ways in which JMS 2.0 enables developers to send and receive messages while writing less code. Some features of JMS 2.0, part of Java EE 7, and can be deployed in Java EE Web or EJB applications, while others can only be used standalone in a Java SE environment.

Deakin writes:

“The single biggest change in JMS 2.0 is the introduction of a new API for sending and receiving messages that reduces the amount of code a developer must write. For applications that run in a Java EE application server, the new API also supports resource injection. This allows the application server to take care of the creation and management of JMS objects, simplifying the application even further…”

The new API, known as the “simplified” API, is simpler and easier to use than the existing JMS 1.1 API, now known as the “classic” API.

Deakin describes the new API as follows:

“The simplified API consists of three new interfaces: JMSContext, JMSProducer, and JMSConsumer:

* JMSContext replaces the separate Connection and  Session objects in the classic API with a single object.

* JMSProducer is a lightweight replacement for the MessageProducer object in the classic API. It allows message delivery options, headers, and properties to be configured using method chaining (sometimes known as a builder pattern).

* JMSConsumer replaces the MessageConsumer object in the classic API and is used in a similar way.”

Developers can now choose between the two APIs and have access to both the classic and new features. Stay tuned for Part Two, in which Deakin will explore new messaging features in JMS 2.0.

Check out Part One here.

Monday Apr 08, 2013

Technical Article: Java EE 7 and JAX-RS 2.0

A new article by Java Champion Adam Bien, titled “Java EE 7 and JAX-RS 2.0” is up on otn/java. The article demonstrates how Java EE 7 with JAX-RS 2.0 has several new useful features which further simplify development, and lead to the creation of more sophisticated Java SE/EE RESTful applications.

Using a Java-friendly, but simplistic JAX-RS 2.0 example Bien takes the reader through aspects, request interception, client and configuration issues and much more. He concludes the article as follows:

“Interestingly, JAX-RS does not even require a full-fledged application server. After fulfilling the specified Context Types, a JAX-RS 2.0–compliant API can be anything. However, the combination with EJB 3.2 brings asynchronous processing, pooling (and so throttling), and monitoring. Tight integration with Servlet 3+ comes with efficient asynchronous processing of @Suspended responses through AsyncContext support and CDI runtime brings eventing. Also Bean Validation is well integrated and can be used for validation of resource parameters. Using JAX-RS 2.0 together with other Java EE 7 APIs brings the most convenient (=no configuration) and most productive (=no re-invention) way of exposing objects to remote systems.”

Check out the article here.

Thursday Sep 27, 2012

Talking JavaOne with Rock Star Raghavan Srinivas

Raghavan Srinivas, affectionately known as “Rags,” is a two-time JavaOne Rock Star (from 2005 and 2011) who, as a Developer Advocate at Couchbase, gets his hands dirty with emerging technology directions and trends. His general focus is on distributed systems, with a specialization in cloud computing. He worked on Hadoop and HBase during its early stages, has spoken at conferences world-wide on a variety of technical topics, conducted and organized Hands-on Labs and taught graduate classes.

He has 20 years of hands-on software development and over 10 years of architecture and technology evangelism experience and has worked for Digital Equipment Corporation, Sun Microsystems, Intuit and Accenture. He has evangelized and influenced the architecture of numerous technologies including the early releases of JavaFX, Java, Java EE, Java and XML, Java ME, AJAX and Web 2.0, and Java Security.

Rags will be giving these sessions at JavaOne 2012:
  • CON3570 -- Autosharding Enterprise to Social Gaming Applications with NoSQL and Couchbase
  • CON3257 -- Script Bowl 2012: The Battle of the JVM-Based Languages (with Guillaume Laforge, Aaron Bedra, Dick Wall, and Dr Nic Williams)


Rags emphasized the importance of the Cloud: “The Cloud and the Big Data are popular technologies not merely because they are trendy, but, largely due to the fact that it's possible to do massive data mining and use that information for business advantage,” he explained.

I asked him what we should know about Hadoop. “Hadoop,” he remarked, “is mainly about using commodity hardware and achieving unprecedented scalability. At the heart of all this is the Java Virtual Machine which is running on each of these nodes. The vision of taking the processing to where the data resides is made possible by Java and Hadoop.”

And the most exciting thing happening in the world of Java today? “I read recently that Java projects on github.com are just off the charts when compared to other projects. It's exciting to realize the robust growth of Java and the degree of collaboration amongst Java programmers.”

He encourages Java developers to take advantage of Java 7 for Mac OS X which is now available for download. At the same time, he also encourages us to read the caveats.

Originally published on blogs.oracle.com/javaone.

Monday Sep 10, 2012

Expressing the UI for Enterprise Applications with JavaFX 2.0 FXML - Part Two

A new article by Oracle’s Java Champion Jim Weaver, titled “Expressing the UI for Enterprise Applications with JavaFX 2.0 FXML -- Part Two,” now up on otn/java, shows developers how to leverage the power of the FX Markup Language to define the UI for enterprise applications. Weaver, the author of Pro JavaFX Platform, extends the SearchDemoFXML example used in Part One to include more concepts and techniques for creating an enterprise application using FXML.

Weaver concludes the article by summarizing its content, “FXML provides the ability to radically change the UI without modifying the controller. This task can be accomplished by loading different FXML documents, leveraging JavaFX cascading style sheets, and creating localized resource bundles. Named parameters can be used with these features to provide relevant information to an application at startup.”


Check out the article here.





Wednesday Jun 20, 2012

Expressing the UI for Enterprise Applications with JavaFX 2.0 FXML - Part One

A new article, the first of two parts, now up on otn/java by Oracle Evangelist and JavaFX expert, James L. Weaver, titled “Expressing the UI for Enterprise Applications with JavaFX 2.0 FXML, Part One,” shows developers how to leverage the power of the FX Markup Language (FXML) to define the UI in enterprise applications.

As Weaver explains, “JavaFX 2.0 is an API and runtime for creating Rich Internet Applications (RIAs). JavaFX was introduced in 2007, and version 2.0 was released in October 2011. One of the advantages of JavaFX 2.0 is that the code can be written in the Java language using mature and familiar tools.”

He goes on to show how to use the potential of FX Markup Language, which comes with JavaFX 2.0, to efficiently define the user interface for enterprise applications. FXML functions to enable the expression of the UI using XML. “Classes that contain FXML functionality are located in the javafx.fxml package,” says Weaver, “and they include FXMLLoader, JavaFXBuilderFactory, and an interface named Initializable.”

Weaver’s article offers a sample application that shows how to use the capabilities of FXML and JavaFX 2.0 to create an enterprise app.

Have a look at the article here.

Wednesday May 23, 2012

Best Practices for JavaFX 2.0 Enterprise Applications, Part Two

Java Champion, Oracle Java Evangelist, and JavaFX expert Jim Weaver, has published Part Two of his article, "Best Practices for JavaFX 2.0 Enterprise Applications" on otn/java. Weaver continues to explore the possibilities of the TweetBrowser application, focusing now on new techniques and best practices that include:

* Leveraging a JavaFX cascading style sheet
* Implementing springs and struts in the UI
* Using a ternary operation in binding expressions
* Defining JavaFX properties
* Leveraging a Popup to implement a dialog box
* Using WebView to display a Web page

As Weaver emphasizes, there is a vast array of techniques and best practices that can be used in JavaFX applications. For example:

The JavaFX cascading style sheet (CSS) enables users to modify the appearance of an application.

The springs and struts concept enables a fixed horizontal strut and a variable horizontal spring so that an application can appear the way developers want it to appear, regardless of the size of the scene or the type of platform.

Go here to learn more about the rich possibilities of JavaFX 2.0 and enterprise applications.

About

Insider News from the Java Team at Oracle!

duke
javeone logo
Links


Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
2
5
6
7
12
13
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today