ebook img

Java Magazine 2012 01-02 PDF

21.2 MB·English
by  Oracle
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Java Magazine 2012 01-02

//JANUARY/FEBRUARY 2012 / 10 33 68 JAVA VS. PROJECT FIX THIS SPAM COIN IS A Test your TIME-SAVER How Java EE is evolving to become the Mollom eliminates knowledge unwanted postings How Java SE 7’s with a Swing cloud computing platform standard from Websites language changes conundrum worldwide streamline your code ORACLE.COM/JAVAMAGAZINE //table of contents / Y T I N U M M O COMMUNITY 41 C 02 Java Architect From the Editor Understanding Hudson N Plug-Ins O 4 I T Our Hudson series continues. Java Nation C A News, events, and happenings 45 N I in the Java community. Rich Client A V JavaFX and Swing A J JAVA IN ACTION Go from Swing to JavaFX. 14 49 The Engine of Choice Enterprise Java H C Java puts Choice Hotels front Lightweight Publish- E and center on Google Maps. T Subscribe A V Adam Bien on CDI. A JAVA TECH J 19 53 New to Java Enterprise Java Shall We Play a Game? GlassFish Clustering and High Availability S Michael Kölling gives us a play- U able version of our turtle game. Scale apps horizontally. T U 22 60 O B New to Java Enterprise Java A Introduction to RESTful Wake Up and Smell Web Services the Coffee Max Bonbhel tackles JAX-WS. Have fun with Java EE 6. 10 26 33 68 30 63 Java Architect Mobile and Embedded Java in Action Cloud/Java EE Java Architect Fix This Looking Ahead to Developing Proximity WINNING THE TAME THE PROJECT Java EE 7 Awareness In this issue’s A tour of Java EE 7 JSRs Use the Location API. WAR AGAINST COIN: code puzzler, SPAM WITH THE JAVA Marek Piechut 37 65 CLOUD JAVA LANGUAGE challenges your Java Architect Polyglot Programmer knowledge of With Dries HAS EVOLVED! Using JLayer in Your Using Maven to Swing. Buytaert at the Additions to the blog Swing Applications Compare JVM Scripting helm, Mollom Oracle’s Cameron Purdy on how Java language Create effortless effects. Languages eliminates Java EE is evolving to become the in Java SE 7 will Give scripting languages a try. unwanted post- cloud computing platform standard help you be more ings from Web- productive. COVER ART BY I-HUA CHEN sites worldwide. PHOTOGRAPH BY DAVE BRADLEY 01 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2012 //from the editor / Y T I N U M M O C N O I T S C A N I A V A J GIVE BACK! H ometimes, buzzwords are for real. Cloud computing is one such example: most will agree that the C E term itself is overused and lacks a clear, universally accepted definition. But we can also agree on the impor- ADOPT A JSR T A tance of understanding cloud computing’s likely impact on the application development process. Pretending V A J otherwise would constitute a serious breach of career-management duty. In some quarters, that impact is expressed in the context of the emerging “DevOps” principle, which calls for developers to use their programming powers to free themselves from the burden of IT operations. Cloud Find your JSR here S computing, by almost any definition, is a key DevOps enabler. U T Currently, the Java EE platform lacks the abstractions that allow Java developers to move confidently in that U O direction. But with Java EE 7 (JSR-342; final release expected later in 2012), that will change—with the inclu- B A sion of updated APIs, roles, and more that will bring support for cloud service requirements such as multi- tenancy, elasticity, and scalability directly into the standard. As a result, apps written to target Java EE 7 app servers (which will in fact become services themselves) will be much more natively cloud-aware than they are today. What could be more DevOps-friendly than that? //send us your feedback / Our interview with Cameron Purdy, Oracle vice president of Java EE development, reveals the reasoning behind these efforts in more detail. (You can also review the We’ll review all suggestions for future Java EE 7 JSRs.) And as usual, you’ll find this issue packed with informative, improvements. actionable articles on other subjects as well—including wrap-ups of JavaOne Latin Depending on volume, America and Devoxx 2011, a Swing JLayer primer by Josh Marinacci, an introduction some messages may to Java SE 7’s Project Coin features by Julien Ponge, and more. Enjoy it! not get a direct reply. blog Justin Kestelyn, Editor in Chief BIO PHOTOGRAPH BY BOB ADLER 02 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2012 //java nation / Y JAVAONE LATIN AMERICA NEWS / T I N U M M O C PROMISES DELIVERED At the Java strategy keynote on the first day of JavaOne Latin America, Oracle N executives stepped through Oracle’s Java technology roadmap for Java SE, Java O NEWS ROUNDUP EE, Java ME, and JavaFX. “Last year at JavaOne Latin America, Oracle was full TI C JavaOne of promises,” said Georges Saab, vice president of development, Java Platform A N Group. “This year we can say Oracle delivered on those promises: Java SE 7, I A JavaFX 2.0, and increasing transparency in the JCP [Java Community Process].” V LATIN A Nandini Ramani, vice president of development, Java client platform, announced J the release of JavaFX 2.0.2. She explained that starting with JavaFX 2.0.2, JavaFX AMERICA is available under the same license and business model as Java SE. This includes the ability to distribute the JavaFX runtime (or Software Development Kit) for H C third-party developers with their application(s), subject to the terms and condi- E 2011 T tions of the license. (Developers can follow and join the JavaFX open source proj- A V ect at OpenJFX.) The technical keynotes on the second day provided more details A J on each of these technologies. Arun Gupta Stephen Chin S Georges Saab U Arun gupta and Stephen Chin T U JavaOne Latin America 2011 O B was held in São Paulo, Brazil, A December 6–8, 2011. The regional JavaOne conference included great FOCUS ON JAVAFX The source code for the Henley Sales keynotes, deep technical sessions, There was lots of buzz around JavaFX. At Dashboard is available as part of the engaging hands-on labs, a bustling JavaFX Sample Showcase (currently the technical keynote, the JavaFX demos only for Windows). Oracle Technology Network lounge, generated the most interest, especially the JavaFX game running on a desktop and two booth swag (Duke T-shirts!), different tablets. The other demo that sparked a lot of interest was the Henley wonderful conversations, and even Sales Dashboard, a client/server application for a fictional global automobile a maté tasting. company. The front end was developed with JavaFX, displaying real-time sales data via MySQL and deployed on Oracle GlassFish Server. At the standing- blog room-only session “XML-Free Programming: Java Server and Client,” Stephen Chin, chief agile methodologist at GXS and Java Champion, and Arun Gupta, Java evangelist at Oracle, discussed how to build Web apps with a JavaFX client and a Java EE server. Nandini Ramani PHOTOGRAPHY BY LOAINE GRONER AND ARUN GUPTA 04 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2012 //java nation / Y JAVAONE LATIN AMERICA NEWS / T I N U M M O Parleys.com Brings C Bruno Souza BEST FOR LAST: THE COMMUNITY KEYNOTE The JavaOne Community Keynote was informative and funny. Fabiane Nardon Sessions to You N and Bruno Souza of Brazilian Java user group SouJava opened the keynote O with their list of the top five developments in Java for the year: 5) Java on Mac TI C to OpenJDK, 4) SouJava and the London Java Community getting seats on the Couldn’t make it to JavaOne or Devoxx? A N JCP Executive Committee, 3) Twitter adopting Java for improved performance, That needn’t stop you from “attending” I A 2) Java SE 7 being released, and 1) JavaFX being made open source. Nardon many of the most important conference V A then discussed women in technology and, with SouJava members Yara Senger, Ana Abrantes, sessions. You can do so at Parleys, the J and Loiane Groner, announced the formation of jDuchessBR, a group for Brazilian women using GlassFish-powered e-learning platform in- Java. Then Vinicius Senger gave a demo of the Duke’s Choice Award winner, jHome, showing that vented by Java Champion, Belgian Java User what you can do with Java is limited only by your imagination: adjust the lights in your house Group leader, and Devoxx Founder Stephan H C via Twitter, brew coffee, or monitor someone’s heart rate remotely (Arun Gupta was the guinea Janssen. The Parleys team recorded 40 per- E T pig). The keynote concluded with cent of the JavaOne 2011 sessions, along with A V a twist on the Java Life video en- a substantial sampling of Devoxx 2011 ses- A J titled Real Java Geeks. See what sions and interviews. Java developers do when they A Parleys technical session presentation aren’t in their cubicles (or offices, provides you with a full educational experi- home offices, or coffee shops). ence, including audio, slides, and video of S U Fabiane Nardon talks about When they’re not coding hard, Java developers surf, hike, ride demos from the sessions. You hear and see T zero downtime and the motorcycles, fish, practice jujitsu, and so much more. almost everything the session’s live attend- U O amazing performance of ees heard and saw—with the added benefit B Java EE. A THE COMMUNITY THAT RIDES TOGETHER . . . that you can pause, back up, and review a Geek Bike Ride In true community spirit, Fabiane Nardon and session segment or slide any time you like. other SouJava members put together a Java com- You can watch Parleys presentations online, munity bike ride the Sunday morning before or you can download them for offline viewing JavaOne Latin America. Nardon arranged for bike using the free Parleys Desktop application. rentals and matching jerseys, and “bike angels” Visit the Parleys JavaOne channel to view made sure no one was left behind. Nearly 30 rid- popular sessions from JavaOne 2011 includ- ers enjoyed slightly overcast and cool weather and ing “Introduction to JavaFX 2.0,” “Java EE 6: a wonderful route through São Paulo, thanks to The Cool Parts,” and “The Heads and Tails of Sunday lane closures just for bicyclists. The riders Project Coin.” looked great in their fabulous Duke bike jerseys. The route was 12 miles (22 kilometers)—check blog out the GPS documentation and full redundancy. The group rode at a leisurely pace that allowed Stephan Janssen everyone to chat and meet new friends. The group even visited two parks and a street fair along talks about the the way. Affectionately called the Geek Bike Ride, it had just the right combination of exercise, challenges of putting on Devoxx. technology, and fun. Watch for #geekbikeride to join or start a community bike ride near you. PHOTOGRAPHY BY ARUN GUPTA AND TORI WIELDT 05 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2012 //java nation / Y T I N Joe Darcy U M M O C N Devoxx O I T Heads C A Richard Bair to France N I A V A To celebrate its 10-year J success, Devoxx will expand to France, in the first conference H C modeled after Devoxx E T in Belgium. At Devoxx A Brian Goetz, Mark Reinhold, Ben Evans V France, April 18–20, Michael Heinrichs A J Devoxx 2011: 2012, 75 percent of Shaun Smith platform-as-a-service enhancements in Java EE the sessions will be in 7 and GlassFish Server Open Source Edition 4. French and 25 percent TECHNICAL IMMERSION Spec leads presented specifics on JSRs: Oracle’s in English. The Paris S Marek Potociar on JAX-RS 2.0 and the upcom- Java user group behind U T Devoxx 2011 celebrated its 10-year anniversary in Antwerp, Belgium, ing and sought-after client API; Oracle’s Shaun this event promises a U O in November 2011. Sold out every year weeks in advance, Devoxx has Smith on JPA 2.1; Oracle’s Nigel Deakin on Java Devoxx experience plus B become the biggest Java developer conference in Europe, with 3,350 Message Service 2.0; and Ehcache Founder Greg spring in Paris and, of A attendees from 40 countries and more than 170 well-known speakers Luck on javax.cache. course, wine. A call for giving 150 sessions over five days. JavaFX 2.0, released at JavaOne, had a papers is open, and The conference is a technical immersion. Junior and seasoned big presence too. Oracle technical leads Jasper Potts, Richard Bair, Oracle is a sponsor. developers learn about platform improvements and better and faster Michael Heinrichs, and John Yoong and two community leaders, Peter application developments with a mix of keynotes, technical overviews, Pilgrim and Stephen Chin, presented seven talks for a full immersion three-hour sessions, hands-on labs, 30-minute “Tools in Action” on features, deep dives about animations and custom bindings, and talks, and the traditional birds-of-a-feather discussions. an open mic session. The “Why We Should Target Women” panel Henrik Stahl and Cameron Purdy of Oracle talked about Oracle’s attracted a full house as well. Only 1 percent of Devoxx attendees are investment in and innovation around the Java platform with the upcom- women, so the discussion centered on encouraging women into the ing releases of Java SE 8, Java EE 7, and JavaFX 3.0. Mark Reinhold, Joe field and the conference. Here are a few of the ideas discussed: It’s all happening in Paris. Darcy, and Brian Goetz, Java SE architects and technical leads at Oracle, 1. Parents should encourage their daughters to play with Legos and explained the latest progress with Project Coin, Project Jigsaw (modu- blog learn programming. larity), and Project Lambda in a series of sessions and casual discus- 2. More organizations should target young women in high school and sions with developers. Java EE 7 development will be multitenant, on college to expose them to programming. Women need mentors demand, and autoprovisioned for the cloud platform. Jerome Dochez, (men or women) to learn to become speakers at conferences and a GlassFish architect at Oracle, discussed cloud infrastructure and to promote themselves better. PHOTOGRAPHS COURTESY OF DEVOXX 06 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2012 //java nation / Y T I N U M M O C Adopt-a-JSR N O I T WHAT’S NEW AT JAVA.NET C A Want to help move Java forward? Is there some specific N I enhancement to the Java platform that would ben- A AFTER A YEAR OF UPHEAVAL AND REBUILDING, JAVA.NET IS GROWING V efit you and your industry peers? Your Java user group A Sonya Barry AGAIN, WITH 80 TO 90 NEW PROJECT REQUESTS PER WEEK, GROWTH IN J (JUG) can make that happen by participating in the MEMBERSHIP, AND NEW COMMUNITY VOLUNTEERS TAKING OVER LEADERSHIP ROLES IN SEVERAL Adopt-a-JSR program. To contribute to a JSR, your JUG COMMUNITIES. Plans for 2012 include new hardware and performance improvements, adding will have to join the Java Community Process (JCP)—a H another level of social and group functionality (starting with Java user groups and then the Java procedure that is being streamlined for JUGs as part of C E Community Process), a complete redesign in how communities are structured, and improve- the JCP’s new openness. JUGs have already contributed T ments to the project catalog and search facilities. Sonya Barry, Java.net community manager, A significantly to changing the JCP through their involve- V says she has heard many great ideas from community members that she will be looking into, A ment in JCP.next. J ranging from opening the API so users can create mobile apps that work with the site and im- As London Java Community leader (and JCP mem- proving search engine optimization on projects and people to using geotags to let users know ber) Martijn Verburg (@Karianna) notes, “there are where their nearest Java user group is. genuine domain experts in JUGs that can serve as EG Java.net blog posts on a variety of topics are receiving considerable attention, and innovative S [Expert Group] members; skilled developers that can U new Java-centric open source projects are underway (and seeking added participation from the help with RI [reference implementations] and TCK T U developer community as well). [technology compatibility kit] implementations; and O Recent Java.net blogs of note include Osvaldo Pinali Doederlein’s JavaFX Balls 3.0, B enthusiastic hordes that can help test early versions, A Mamadou Lamine Ba’s What JSF Should Become?, Santiago Pericas-Geertsen’s JAX-RS 2.0— give feedback, and help deal with project overheads Client API, Cay Horstmann’s Operator Overloading Considered Challenging, and Tushar Joshi’s such as mailing lists and issue trackers as well as pro- Concentrating on Task in Hand (Similar to Mylyn) in NetBeans IDE. moting the JSR in general.” Innovative new Java.net projects include JSF extension points, an easy-to-use, powerful drop-in/plug-in system for Java EE; SWELL, an English-like domain-specific language for Swing testing; and the Vorpal XMPP Component Framework, an injection-based XMPP com- ponent framework for Jabberwocky. More than 2,200 diverse Java.net open source projects are available. They welcome your participation. Martijn Verburg explains the Tori Wieldt talks Adopt-a-JSR program. blog with Sonya Barry about the Java.net migration. PHOTOGRAPH BY CAITLIN YOUNGQUIST 07 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2012 //java nation / Y T I N U M M O C Twitter and Azul Elected to the JCP EVENTS N O Twitter and Azul Systems were elected to the Java Community I T Process (JCP) Standard/Enterprise Edition Executive MOBILE WORLD CONGRESS FEBRUARY 27–MARCH 1, BARCELONA, SPAIN C A Committee (EC) in the JCP’s fall 2011 election. The companies N I bring widely recognized expertise in Java Virtual Machine “ Redefining mobile” is the theme of A V (JVM) performance to the JCP at a critical time in the history this year’s mobile technology and A J of Java’s evolution. business conference. More than hbCyoa dmre ampclhaucineinivtegyd’ ts h ahe tiighrh rReluye b-sticya Imonlna eAb sRpl eapr iieNlls r2If sOo0tr a1cm0clik,ea Tnnwwtci/teihtts ie mearr vnp eeernrow gsv oieJnacmevkaeee rtnss fet ra riavnnmin cTeoew wubinttuocreilkert, d s oN etneha tttrahctyhe .t ,hAJ iBetno y ps sa rt a rgte: t Boanr ce eflroonma –R oy no uS eclalen r s 6fcaoon0rnd ,t0f hae0iwrse0 aen ravcdtteesn e pptnr,r odowgeghreraiascm mhar ,.i e neA xecphlxuppibd ePiecltiasto enande , t , A TECH V JavaOne, Twitter’s Attila Szegedi spoke about the team’s accomplishment at the a conference in its own right, is the A J session “Everything I Ever Learned About JVM Performance Tuning at Twitter.” Azul world’s largest gathering of apps develops high-performance Java products, such as the Linux-optimized Zing JVM developers—more than 10,000 and the C4 Pauseless Garbage Collector. The companies were elected to the two are expected. open election EC seats out of an unusually large field of nine candidates. FEBRUARY Jfokus 2012 MARCH S U Java Performance FEBRUARY 13–15, QCon London 2012 T U NetBeans IDE 7.1 Released Tuning Workshop STOCKHOLM, SWEDEN TRAINING MARCH 5–6, O Jfokus is the largest annual B FEBRUARY 6–9, SYDNEY, CONFERENCE MARCH 7–9, A conference for anyone AUSTRALIA LONDON, ENGLAND NetBeans IDE 7.1, launched in January 2012, is the first integrated who works with Java in This four-day course will QCon London is the sixth development environment (IDE) to support JavaFX 2.0. Developers Sweden. The conference be led by Kirk Pepperdine, annual London enterprise can create JavaFX applications completely in the Java programming is arranged together with Java performance tuning software development language using industry-leading development support provided by Javaforum Stockholm, a expert, Java Champion, conference designed for Swedish developer com- NetBeans. Also available is support for creating JavaFX FXML–based and international speaker developers, team leads, munity and Java user applications or traditional Java-based JavaFX applications, and JavaFX and trainer. Each day will architects, and project group. With speakers Preloader applications to customize the startup experience of a JavaFX application. have a topic: introduction managers. Day two of the from Sweden and around Developers can also package their applications as a standalone application, a Java to performance, the Java development track focuses the world, the conference Web Start–based application, or an in-browser application. Debugging the JavaFX Virtual Machine, tooling, on hard-core Java. focuses on development application UI is now simplified with the new GUI visual debugger, which can also be and performance tuning with Java and surrounding used with Swing-based UIs. in practice. techniques. blog This release introduces batch refactoring tools that enable projectwide refactorings, including an extensible “inspect and refactor” tool, new refactorings and code hints, a block selection mode, and an import statement organizer, among many other Java edi- tor enhancements. NetBeans IDE 7.1 supports Oracle WebLogic Server 12c, providing industry-leading Java EE 6 support to developers using the Oracle WebLogic platform. ILLUSTRATION BY I-HUA CHEN, PHOTOGRAPH BY RON SELLERS 08 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2012 //java nation / Y T I N U M JAVA BOOKS M O C N O I T C A N I A V A J JAVA PROGRAMMING JAVA 7 NEW FEATURES JAVA 7 FOR ABSOLUTE MURACH’S JAVA Charles Oliver Nutter Agnes Crepet Andrew Lee Rubinger By Poornachandra Sarang COOKBOOK BEGINNERS PROGRAMMING, H Oracle Press (January 2012) By Richard M. Reese and By Jay Bryant 4TH EDITION C Heroes of Java Jennifer L. Reese Apress (December 2011) By Joel Murach E Java Programming fea- T Packt (May 2012) Mike Murach & Associates A tures hands-on program- Java 7 for Absolute V (November 2011) A There are many heroes of Java out there—people ming exercises and exam- Java 7 New Features Beginners introduces the J who are making significant contributions on a daily ples based on the author’s Cookbook offers a prac- new core open source Java Get a fast start in Java, basis within the Java ecosystem, thereby building 10-plus years of teaching tical, recipe-based ap- Development Kit. The and then master all the Java’s future in the most practical way possible. Java to experienced pro- proach for learning about book focuses on practi- core skills you need to Often their work is performed far away from the fessionals. This Oracle the new features of Java cal knowledge, providing be a professional Java S U public spotlight. Software architect and author Press guide covers all the 7. The book starts with all the bits and pieces an developer. By the end T U Markus Eisele is highlighting these people and new Java features, includ- coverage of new lan- utter novice needs to get of Chapter 6, you’ll be O their efforts in his new interview series, The Heroes ing multilingual support, guage improvements. started programming in writing fail-safe, object- B A of Java. support for JavaScript and Subsequent chapters Java. The book teaches oriented applications The series is not about celebrities; rather, the other scripting languages, address new features of Java development in a with business classes and focus is on “people displaying courage and some- JavaFX, and several other Java 7 while incorporat- language that anyone can objects. By the end of the times even self-sacrifice for the greater good,” modifications to the lan- ing these new language understand. It provides book, you’ll be working says Eisele. Heroes in the series include Marcus guage. Java programmers improvements when simple, step-by-step ex- comfortably with features Lagergren, Oracle JRockit architect and team lead; will find exactly what they possible. Content includes amples that make learn- such as inheritance, inter- Andrew Lee Rubinger, JBoss software engineer; need to know in order to NIO techniques, GUI ing easy, allowing you faces, arrays, collections, Cay Horstmann, author and professor; Charles integrate these new fea- improvements includ- to pick up the concepts. threads, GUIs, files, and Oliver Nutter, JRuby developer; and Java user tures into their skill set. ing window methods, the It also offers clear code databases (using JDBC). group leaders Martijn Verburg and Agnes Crepet. The author also provides new JLayer class, various descriptions and layout At every step, you’ll save If you’d like to suggest someone worthy of inclu- thorough coverage of Java dialog-box-related meth- so that you can get your time by using NetBeans. sion in the series, Eisele invites you to post a com- syntax, the event model, ods, and much more. The code running as soon as Read a sample chapter. blog ment to his lead Heroes of Java entry. threads, network pro- book is currently available possible. gramming, I/O program- as a RAW book (read as it ming, and applets. is written). PHOTOGRAPHS COURTESY OF MARKUS EISELE 09 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2012

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.