Showing posts with label Java7. Show all posts
Showing posts with label Java7. Show all posts

Tuesday, 4 October 2011

JavaOne 2011 - Days 1 and 2 (Sunday/Monday)

Hi all,

So I'm at JavaOne and it's been an interesting first couple of days!  I'm live tweeting a number of live announcements and insights but I thought I'd try to round-up my experiences so far on Days 1 and 2.

Apologies for anyone/thing I've missed - it's been a whirlwind! 

Sunday


My Walk

I started the day with an interesting walk from my apartment to "The Zone".  First thing that struck me was the vast numbers of homeless people on the streets, really sad to see and not what I expected from San Fran at all.  They say that Britain is a broken society, I think I'm seeing worse here in San Fran.

JUG Leaders Brunch

The JUG Leaders and Java Champions brunch was the first thing up on Sunday morning.  It was fantastic to put names to faces (a bunch of us only knew each other from the mailing list) and of course to see familiar friendly faces including Stephen Chin, Bruno Souza, Fabiane Nardon, Kirk Pepperdine, Stephan Janssen and many more! Oracle gave us a briefing on what was going to be announced in the keynotes, one of the focuses being on Java FX 2.0. I'm still personally not sure whether it's going to be 'too little, too late' given the rise of HTML5, but then again I'm not heavily involved in the UI space.

User Group Sunday

The rest of Sunday was spent with the JUG leaders and other community members for a bunch of Open Conference style sessions.  It's always good to discuss the issues that we all commonly face, thanks to John Yeary for organising.

The Duke awards were presented that evening outside in the Mason Street tent/cafe area and LJC's Trisha Gee accepted a Duke innovation award for the Disruptor framework that her company (LMAX) has been working on.  The Zero Turnaround guys also picked up their well deserved award for JRebel.

The evening ended with us meeting up with Charles Nutter and some of the other JRuby crowd at the Glassfish party in the Thirsty Bear, it never hurts to get free beer! Was also nice to see Dan Hardiker and a certain Mr Gosling there.

Monday

The Good

1. Oracle's stance and genuine efforts with the community.
  • The Duke awards on Sunday night
  • The free coffee and beer
  • Featuring non Oracle speakers on the JavaOne front page
  • The technical content of the overall program being determined in conjunction with a community committee.
  • Their community interviews
  • And more!
Credit goes to all of the Oracle team behind this including Nichole Scott, Sharat Chandar, Mark Reinhold, Henrik Stahl, Adam Messinger, Mary-Lou, Tori Weildt, Dalibor, Donald and many more!

2. Parts of the Keynote were really good.  Mark Reinhold was very clear explaining Java 7 and 8, the Java FX 2.0 demo with the Kinect controlled Duke went down well and they involved the JRuby guys to explain invokedynamic and what it means for non-Java languages.

3. The Mason Street area and the hangout spaces in the hotels are pretty cool

4. Attendance was way up from last year, real buzz about the place, it's pretty clear that the Java platform is going through an upsurge, exciting to see.

5.  JCP matters again.  We had lots of people turning up to the JCP events, buoyed by the results of JSR-348 (step one in reforming the JCP) with lots of feedback and interactive Q&A.  Even the public EC meeting was packed out!  I was on the panel for a number of these events and was really happy with the amount of interest and feedback, especially considering they're effectively non-technical sessions.

6. Good talks on Lambda (Alex Buckley) and Jigsaw (Mark Reinhold) for Java 8 from experts who actually engaged the audience!

7. The O'Reilly cocktail party, was able to talk shop with fellow authors and catch up with friends from OSCON such as Laurel Ruma, Sarah Novotny and the rest of the O'Reilly crew.

The Indifferent

1. Oracle have tried their best with "The Zone", but the fact remains that running around the 3 hotels is still fairly difficult and trying to find certain rooms inside the hotels also leaves attendees missing out on their events.  I haven't put this into "The Bad" section as the sign posting and extra helpers made it bearable (just).

2. The speakers room was very small and has limited WiFi signal, Oracle, please talk to the OSCON folks on their set-up!

3. Getting my photo taken in an alleyway in the rain for a tech magazine - us developers don't usually make good models, as was proven today!

4. Some of the even rooms are still small and pokey and seem to be stuck in a basement level (Parc55 in particular)

The Bad

1.  The WiFi constantly drops in and out, ruining some presenters demos and causing immense frustration for attendees.  Lessons need to be learned from some of the European conferences such as Devoxx and FOSDEM.  Hoping this improves tomorrow.

2. The Intel part of the keynote.  Caused the entire keynote to be late (they rambled on), was boring (some pretty hokey bar/line graphs) and the its content was better suited to OOW as opposed to JavaOne.

Phew - busy days so far, looking forward to sleep :-)

Cheers,
Martijn

Thursday, 15 September 2011

My Interview with MyFear

I was humbled to be interviwed as part of MyFear's Java Hero's series - If you want to know some of my motivations then go here

Saturday, 10 September 2011

The OpenJDK as the default Java on Linux

Hi All,  (this post is x-posted to the java7developer blog and the ljc blog)

Recently I've received a bunch of private correspondence from people confused/worried over the change in the default Java packaging for Linux. For many Linux distributions, the official Sun/Oracle version of Java has been packaged up as the default Java for the platform. However, due to a recent licensing change, this will no longer be the case! So, is this a positive or a negative thing for the Java and open source ecosystem? Read on for my take on it :-)

Background

Dalibor Topic announced that With Java SE 7 and JDK 7 being released, and with OpenJDK as the official Java SE 7 reference implementation, that it was finally time to retire the non open source "Operating System Distributor License for Java" (DLJ).

What does it mean for me?

The knock on effect of this is that Linux distributions will on longer package Oracle's Java (== OpenJDK wrapped up in some proprietary bits and pieces) as the default Java. This can/will cause problems for some Java users initially as there are a smattering of bugs (especially in the Swing UI libs) still left in the OpenJDK that affect programs like PCGen. However, some Linux distributions had already taken this path some years ago, most notably Ubuntu and the last remaining bugs are being cleaned up pretty quickly.

Positive or Negative?

Overall, I think this is a positive step in the right direction for free and open Java on Linux platforms. This sentiment was welcomed by well known open source advocate Simon Phipps in a twitter post. The fact the the OpenJDK is now the reference implementation (combined with efforts to open up the issue tracker for the OpenJDK) means that means that a vast host of Java/Linux end users can now directly improve 'official Java' for all of us. 

I want the Oracle version!

Linux users who need to use the proprietary parts of the Oracle JDK 6 or Oracle JDK 7 binaries can of course as usual simply get the gratis download at http://oracle.com/java under the same terms as users on other platforms. However, if it is due to a 'bug' that is discovered I strongly encourage those users to submit a bug report to the OpenJDK project, so that any issues can be fixed for all of us.

Opinions and further questions are welcome!

Thanks,
Martijn

Thursday, 1 September 2011

JavaOne schedule

Here is my JavaOne schedule:  I can't mimic the nice colouring that Steve On Java has, but hey :-).


Please note the JCP EC meeting is open and free for all to join (Sunday 15:45) - we need the voice of the community there, so come along!


I'll actually be speaking at:


  • 30440 - Java User Groups and the JCP (Sunday 14:30)
  • 23647 - JCP and the Developer Community (Monday 11:00)
  • 23641 - Meet the Executive Committee Candidates (Monday 1900)
  • 23645 - Lightning Talks: JSRs in Progress (Wednesday 0830)
  • 25303 - The Diabolical Developer (Redux)  (Wednesday 1500)
  • 25303 - The Diabolical Developer (Redux) - repeat!  (Wednesday 1630)
  • 37780 - Java Community Keynote (Thursday 0845)


Let me know if you want to catch up!  I'll be fairly flexible about turning up to most sessions, the benefit of attending a conference like JavaOne is as much isn't catching up with friends an colleagues as much as anything else :-)


Monday, 23 August 2010

Dependency Injection in Java 7

Hi all,


So apart from recovering from a long bout of the stomach flu, enjoying good food again at a "Come dine with me" night (our parents would be so proud) and planning a rush trip to Vegas I've managed to get out a first draft of the Dependency Injection chapter for the Well Grounded Java 7 Developer.


Java 7 unifies some of the basic standards that the various Dependency Injection frameworks (Spring, Guice, PicoContainer etc) have, making it easier for developers to move between the frameworks as needed.


A reminder of what DI is with regards to Java[1]

The javax.inject package specifies a means for obtaining objects in such a way as to maximize re-usability, testability and maintainability compared to traditional approaches such as constructors, factories, and service locators (e.g., JNDI). This process, known as Dependency Injection, is beneficial to most nontrivial applications.


So without further preamble, here's a short section from the chapter, let me know what you think!


Inject annotation

The @Inject annotation interface can be used in three places to indicate where you'd like a dependency to be injected.  Below are the types of members that can be injected, in the order that they are processed at runtime:

1.   Constructors
2.   Methods
3.   Fields

You can annotate a constructor with @Inject and expect its parameters to be provided at runtime by your configured IoC container e.g:

@Inject public MurmurMessage(Header header, Content content)
{
    this.header = header;
    this.content = content;
}

In this case both the Header and Content parameters would be injected at runtime.  The specification allows for 0+ parameters to be injected for constructors, so injecting a zero-parameter constructor is still valid.

WARNING As per the specification there can only be one constructor in a class with an @Inject annotation, this makes sense as the JRE would not be able to decide which injected constructor took precedence.

You can annotate a method with @Inject and like a constructor, expect its 0+ number of parameters to be injected at runtime.  There are some restrictions in that injected methods cannot be declared abstract and cannot declare type parameters of their own[1].  The short code sample below demonstrates the use of @Inject with a setter method, a common technique when using Dependency Injection.

@Inject public void setContent(Content content)
{
    this.content = content;
}

This technique of method parameter injection is especially powerful when it comes to providing service methods with the resources they need to do their job.  For example you could pass a DAO argument to a finder service method that was tasked to retrieve some data.

TIP It has become a default best-practice to use constructor injection for setting mandatory dependencies for a class and to used setter injection for non-mandatory dependencies, e.g. fields that already have sensible defaults.

It is also possible to inject fields (as long as they are not final), however the practice is not common.  The syntax again is quite simple.

public class MurmurMessenger
{
    @Inject private MurmurMessage murmurMessage;
    ...
}

You can read further about the @Inject annotation in the Javadoc, where you can discover some nuances about what types of values can be injected and how circular dependencies are dealt with.

Cheers,

Monday, 9 August 2010

A Little Directory love

Hi all,

So my next little snippet also comes from Chapter 2 of the book where we deal with the new NIO.2 (Non-Blocking I/O 2) APIs being introduced to Java 7.  In particular I'm showing a small code snippet to showcase some of the new support for directories that Java 7 has.  The code sample certainly needs a little tidy-up by using the new Automatic Resource Management (ARM) features in Java 7, but for now the example will suffice.


Dealing with Directories

The java.nio.file.DirectoryStream interface and its implementing classes allow you to:

  • Iterate over entries in a directory.
  • Deal with large directory structures.
  • Filter entries whilst processing using regular expressions and MIME based content detection.
  • Walk the tree structure in order to perform recursive move, copy, delete operations.
A common use case here is to list entries in a directory, e.g. Java source files as shown by the listing below.

DirectoryStream stream = null;
try
{
    // Define the directory
    Path dir = Paths.get("c:\\workspace");

    // Declare a filtering stream
    stream = dir.newDirectoryStream("*.java");
    // List each .java file in that directory
    for (Path entry: stream)
    {
        System.out.println(entry.getName());
    }
}
catch (IOException e)
{
    // Poor man's exception handling
    e.printStackTrace();
}

As you can see, with the new Java 7 APIs this particular task is much simpler than it used to be and this theme is prevalent in the rest of the NIO.2 APIs.

There are several other use cases which we will show case in the "NIO.2 in action" section.as well as on our upcoming website (to be revealed later).


So are we there yet?  In terms of File and Directory interaction in Java 7 there's certainly a massive improvement, so I'll say "Yes" once Java 7 is released.

Cheers,
Martijn

Thursday, 5 August 2010

The Well Grounded Java 7 Developer

Hi all,

I've obviously not posted for quite some time and here is the reason why.....

It's been a long time coming, but I'm very happy to announce that Ben Evans and I have been contracted to write "The Well  Grounded Java 7 Developer" for Manning publications.  We've been spending the last month frantically getting the first few chapters out and a whole host of other book related activities, but now that I'm in full chapter writing mode I'll be adding regular posts to this blog.

A majority of my future posts will focus on interesting areas in this book and firstly I'd like to show a reworked extract from the new Date and Time API section.

Modeling Date and Time

The new API models time as a sequence of consecutive instants separated by fixed durations[1].  Java 7 maps these concepts directly on to classes, here's a more detailed explanation:
  • The javax.time.Instant class represents a specific point on a discrete time-line e.g. January 23rd, 1996 at 09:00:00,0 UTC, the day that Java 1.0 was released.
  • The javax.time.Duration class represents a section of elapsed time in nanoseconds, e.g. The 400 nanoseconds it takes for a PIC12C672-04 Microchip to execute an instruction set.

So as you can imagine, any point of time can be modeled by simply applying a Duration (positive or negative) to a starting Instant.
...
...

Calendering

With regards to calendaring, the main Calendar is ISOChronology, but other calendars such as CopticChronology and ThaiBuddhistChronology are supported.  The Chronology interface can be extended from to provide other implementations.
...
...

Timezone support

Timezone support is also provided via three core classes:
  • LocalDateTime – Represents date/time without an offset or a time zone.
  • OffsetDateTime - Represents date/time with an offset but not time zone.
  • ZonedDateTime - Represents date/time with an offset and a time zone.
...
...


[1]               This phrase is almost 100% uplifted from an excellent early primer article by Jesse Farnham, see  http://today.java.net/pub/a/today/2008/09/18/jsr-310-new-java-date-time-api.html for details


The book will be loaded with more in depth explanations and of course plenty of code samples.  If you're interested in becoming a reviewer then please let me know!