aspose file tools*
The moose likes Features new in Java 7 and the fly likes Well Grounded Java Developer content question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Features new in Java 7
Bookmark "Well Grounded Java Developer content question" Watch "Well Grounded Java Developer content question" New topic
Author

Well Grounded Java Developer content question

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
OK, I'll bite:

what's in java 7 to make me upgrade?
what's in the book to warrant a purchase?

disclaimer: desktop applications is my 'java' only interest.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Michael,

Well for me if it's a straight out of the box thing, I'd upgrade to Java 7 for:

* try-with-resources which will stop you from making mistakes when you close off Network, File and JDBC based resources (they got this wring 65% of the time in the JDK itself!)
* Speed - In various benchmarks we see anything from a 5-15% performance improvement out of the box
* MethodHandles and MethodTypes - Reflection done in a faster and safer way

In terms of the book, we're aiming it at the Java developer who wants their passion re-ignited and who's looking to the future. There are some industry trends (multi-core processors, the need to rapidly develop web based apps etc) which means that topics like concurrency, build and CI and polyglot programming are of vital importance. But you can see this for yourself in our Table of Contents :-)


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1772
    
  14

Martijn Verburg wrote:* MethodHandles and MethodTypes - Reflection done in a faster and safer way

To what extent are the dynamic JVM languages that use reflection (e.g. Groovy) able to take advantage of this right now?


No more Blub for me, thank you, Vicar.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I'll let Ben reply with more detail (as he's deeper into the tech around that space) but in short, the latest versions of those dynamic languages can take advantage of them now (as well as the new invokedynamic byte code instruction). IIRC Groovy 2.0.x does so already (although it has to gracefully degrade if it's running on a Java 6 or below runtime).
Ben Evans
author
Greenhorn

Joined: Jan 17, 2011
Posts: 20
    
    5
Michael Dunn wrote:OK, I'll bite:

what's in java 7 to make me upgrade?
what's in the book to warrant a purchase?

disclaimer: desktop applications is my 'java' only interest.


For desktop applications, you should definitely upgrade for any greenfield projects.

Swing is officially deprecated, and will not receive any further updates (except possibly critical security patches). JavaFX (which is now bundled with the core Java download) is the way to go.
Michael Swierczek
Ranch Hand

Joined: Oct 07, 2005
Posts: 107
    
    1
Thanks for the discussion, I had not realized Swing was deprecated and replaced by JavaFX in Java 7.
Ben Evans
author
Greenhorn

Joined: Jan 17, 2011
Posts: 20
    
    5
chris webster wrote:
Martijn Verburg wrote:* MethodHandles and MethodTypes - Reflection done in a faster and safer way

To what extent are the dynamic JVM languages that use reflection (e.g. Groovy) able to take advantage of this right now?


There are two parts to this - first off by replacing uses of Reflection with Method Handles (possibly via the Lookup.unreflect() mechanism). Then there's dynamic dispatch of methods, which can be repatched to use actual invokedynamic bytecodes.

The two most advanced mainstream languages are JRuby and Groovy 2.0 - backporting is obviously a concern as these APIs just don't exist in Java 6.

Other languages, like Mark Roos's version of Smalltalk are Java 7-only and use invokedynamic extensively.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1085
    
  10

Actually for Swing, from Java 7, Nimbus becomes the default look & feel.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Ben Evans
author
Greenhorn

Joined: Jan 17, 2011
Posts: 20
    
    5
Ranganathan Kaliyur Mannar wrote:Actually for Swing, from Java 7, Nimbus becomes the default look & feel.


"Is JavaFX replacing Swing as the new client UI library for Java SE?
Yes. However, Swing will remain part of the Java SE specification for the foreseeable future, and is included in the JRE. On one hand, Swing is widely used in existing Java desktop applications, but relies on an old architecture, which requires a certain level of expertise and specialization." - From the official JavaFX FAQ.

From speaking to folks at Oracle, they are not developing the Swing platform any further - the resources for development of a client Java platform are being devoted to JavaFX instead.
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1772
    
  14

Michael Swierczek wrote:Thanks for the discussion, I had not realized Swing was deprecated and replaced by JavaFX in Java 7.

If you're thinking of going polyglot, you might be interested in the GroovyFX project.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1085
    
  10

Ben Evans wrote:From speaking to folks at Oracle, they are not developing the Swing platform any further


That is very true.

Nimbus was bundled only from Java 6 Update 10, so, it did not become the default for 6. For 7, it became default. This means all existing swing applications without a set l&f will use Nimbus if they are running on JRE 7+.
However, the timing of Nimbus is very poor. By the time everyone moves to Java 7, everyone will propably be looking at JavaFX for new stuff. Would have been much better had it been shipped with 6 from the beginning.

But, I think there is also a possibility of people waiting till Java 8 when JavaFX is fully integrated.
Michael Swierczek
Ranch Hand

Joined: Oct 07, 2005
Posts: 107
    
    1
chris webster wrote:
Michael Swierczek wrote:Thanks for the discussion, I had not realized Swing was deprecated and replaced by JavaFX in Java 7.

If you're thinking of going polyglot, you might be interested in the GroovyFX project.


Thank you for your reply, but I was only interested in the replacement of Swing as a curiosity. I'm trying to make the polyglot move to Scala with Play Framework 2.x.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Michael Dunn wrote:
what's in java 7 to make me upgrade?.

There have been whole lot of changes as part of NIO2 in the java.nio.file package like java.nio.file.Files, java.nio.file.Path. Then there's is WatchService API which can be used to monitor a directory for changes like creation, update, delete. And there is API to obtain file metadata. I think these features would be quite a lot useful in Java Desktop applications. Then those who are interested in concurrent applications- you have ForkJoin framework which leverages ExecutorService to implement task stealing algorithm whereby one can spawn out multiple tasks and perform the operations concurrently in each task.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Ben Evans wrote:Swing is officially deprecated

Do you have a link to an Oracle page that says that?

Michael Swierczek wrote:Thanks for the discussion, I had not realized Swing was deprecated

It isn't. Swing is in maintenance mode, which means no new API.

IMO it'll be quite some time before JavaFX can be regarded as a complete replacement for Swing. While rich in fancy features, it is far less amenable to customization.


luck, db
There are no new questions, but there may be new answers.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

Krish Ghata,
Your post was moved to a new topic.


[My Blog] [JavaRanch Journal]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
thanks for all the very informative replies.
now convinced to upgrade to Java 7.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Darryl Burke wrote:
Ben Evans wrote:Swing is officially deprecated

Do you have a link to an Oracle page that says that?

Michael Swierczek wrote:Thanks for the discussion, I had not realized Swing was deprecated

It isn't. Swing is in maintenance mode, which means no new API.

IMO it'll be quite some time before JavaFX can be regarded as a complete replacement for Swing. While rich in fancy features, it is far less amenable to customization.


Hi Darryl, You're quite right - it's not officially deprecated (no deprecated annotations etc), but it's pretty clear that the writing is on the wall. In terms of JavaFX, with version 2.2 (at using Netbeans 7.2) I'm happy using it as a replacement for most cases where I'd use Swing, but I appreciate it's still got 3-6 months to go before most people will simply use it out of the box.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Martijn Verburg wrote:
Darryl Burke wrote:IMO it'll be quite some time before JavaFX can be regarded as a complete replacement for Swing. While rich in fancy features, it is far less amenable to customization.


Hi Darryl, You're quite right - it's not officially deprecated (no deprecated annotations etc), but it's pretty clear that the writing is on the wall. In terms of JavaFX, with version 2.2 (at using Netbeans 7.2) I'm happy using it as a replacement for most cases where I'd use Swing, but I appreciate it's still got 3-6 months to go before most people will simply use it out of the box.

You mean in 3-6 months, there will be a JavaFX Spinner and API to save a JavaFX Image to disk?

And sorry, when I said that JavaFX is less amenable to customization, I meant customization in the area of business logic: custom models/selection models etc. which are the forte of Swing. With CSS support, visual customization is easier than in any earlier Java API.

I think JavaFX will only bloom with the introduction of lambda expressions in Java 8, which I believe will reduce the presently verbose binding codes to one-liners. Provided the holes in the API are filled.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Well Grounded Java Developer content question