Giving Java 8 a spin using NetBeans 7.4 RC

Lucas Jellema
0 0
Read Time:2 Minute, 17 Second

Being at JavaOne 2013 has inspired me to heed the call to option from the Java team at Oracle and give JDK 8 Early Adopter a spin. This article describes how to get from zero to running your first Lambda expression in a Java 8 program in about 10 minutes. It is definitely not a hard task. After going through these steps, you are ready to really start trying out Java SE 8 (including that long awaited new Data API).

The steps are simply:

  • Download JDK 8 EA
  • Download NetBeans 7.4RC1
  • Install JDK 8 EA
  • Install NetBeans 7.4RC1
  • Run NetBeans and create a new Java project

The steps in detail:

1. Download JDK 8 EA

Go to : https://jdk8.java.net/download.html en download JDK 8 Early Adopter

2. Download NetBeans 7.4RC1

Now you are ready to start installing. I happened to use Windows7 as my operating system but the steps on Linux are very similar:

image

3. Install JDK 8 EA

Run the JDK 8 installer and click through the installation steps

image

image

image

image

image

And you are done.

4. Install NetBeans 7.4RC1

Run the NetBeans installer.

image

image

image

image

image

image

This is an important step: this is where you select the JDK to use with NetBeans; in this case this would have to be the JDK 8 that we have just been installing. Note: you can also configure the JDK of choice later on in the netbeans.conf file.

image

Complete the installer wizard to make the installation start.

image

The netbeans.conf file contains the JDK reference:

image

5. Run NetBeans and create a new Java project

image

image

Create a new project of type Java Application.

image

Provide a name and the target directory for the application

image

Press Finish.

Then edit the class LambdaTrial, for example with the following code that makes use of a Lambda expression (that is passed to the sort method call on Arrays):

Now run the application, and see the effect of the Lambda expression:

package lambdatrial;

import java.util.Arrays;

public class LambdaTrial {

   public static int myCompare(String in, String out){
       System.out.println("Compare "+in+" and "+out);
        return in.length() - out.length();
    }

         
    public static void main(String[] args) {
        String[] strings = new String[] {"Pear","Pineapple","Apple","Lemon"};
        
        Arrays.sort(strings, LambdaTrial::myCompare);
        for(String fruit: strings) {
            System.out.println(fruit);
                    
    } 
}

}

image

This demonstrates that with very little effort, we can create Java SE 8 code and run it. I can only suggest you try it out for yourselves.

Resources

NetBeans 7.4RC1 Information, Download Link & release notes: https://netbeans.org/community/releases/74/

NetBeans installation instructions: https://netbeans.org/community/releases/74/install.html

NetBeans configuration of JDK: http://wiki.netbeans.org/FaqJdkHome

Download JDK 8 Early Adopter: https://jdk8.java.net/download.html

About Post Author

Lucas Jellema

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Kubernetes & Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press book Oracle SOA Suite 12c Handbook. Frequent presenter on user groups and community events and conferences such as JavaOne, Oracle Code, CodeOne, NLJUG JFall and Oracle OpenWorld.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
Next Post

You consolidated your applications in one database, but now one application needs recovery...

Imagine this: You have consolidated you applications into one database (version 10gR2). You take a full backup every Tuesday and Thursday evening and an archivelog backup every few hours. These backups go to an NFS share, and not straight to tape. Everything is running fine until one day a new […]
%d bloggers like this: