Java EE6 Virtual Conference

26 12 2009

For those who could not attend the conference (sorry, not my timezone!), here the screencasts (you need a SDN account)

www.sun.com/events/javaee6glassfishv3/virtualconference





Netbeans 6.8, Glassfish V3 and JavaEE6 released

15 12 2009

The waiting is over, finally we get our hands on a production release of EE6 and Glassfish V3. Last week (Dec 10th) released, you also get it together with Netbeans 6.8. There is lot of attention and coverage on the latest version of the enterprise platform, so I spare you from my personal views,  though I was really looking forward to use it beyond previews and beta’s. I am excited to work with the matured and now “rightsized” framework. Time to get active on writing tutorials and books.

Some useful links with more details:





How to add Javadoc to Netbeans

8 05 2009

You are wondering why Netbeans give you code completion but no javadoc, rather saying “javadoc not found” ? It is not part of the Netbeans Installer or the regular JDK package. You need to download it separately (link), copy the zip file to a folder of your choice and configure the javadoc in Java platforms.

Netbeans Java Platform

Netbeans Java Platform

Netbeans Java Platform

Netbeans Java Platform





News: Java JDK 6 Update 12 out

4 02 2009

Latest version from SDN (link).





How to get started with Prefuse and Netbeans

30 01 2009

I was looking for a java based visualization toolkit for quite a while. Either they are very static (image rendered and delivered without any interaction) or cost too much money or badly documented or plain buggy and incomplete. I found a toolkit called prefuse (link) on sourceforge which is an amazing piece of work done by Jeffrey Heer (link) of Berkeley University Stanford. Thanks for this and to the people in the forum (link) to continue the effort to answer questions.

Though it’s last release if dating 2007.10 it is feature complete and not really need to carry the beta tag, but never mind. The project migrated to flare (link) based on Flash and AS, but unfortunately that is not always the first choice, even more powerful in terms of graphics. But I wonder what would be missing. It is open source, so with community effort things can be implemented or even added.
It is released under BSD and can be used freely for commercial and non-commercial applications.

I am a true Netbean nerd, aka NB user and spent some time to get started with prefuse.

Today I wan to share with you the steps (i did) to get a running with prefuse and Netbeans running Windows.
(Please note, it might not be the perfect or smartest approach. I dont claim its the right way or complete, but I got it to work this way. )
I am sure this is very basic information for the prefuse experts, but other beginners might need to go through the same steps.

1. Donwload the file prefuse-beta-20071021.zip (link).

2. Unzip the file to folder.

3. Check for a properly set JAVA_HOME path, like

E:\Documents and Settings\SAM>echo %JAVA_HOME%
E:\Program Files\Java\jdk1.6.0_10

4. Open the file build.bat with text editor of your choice and change the follwoing line
%JAVA_HOME%\bin\java.exe -Dant.home=…
to
java.exe -Dant.home=…
(I removed the JAVA_HOME because java already is in the system PATH)

5. Open a DOS-Box (Windows, aka run.. CMD) and navigate to the folder with the build.bat file.

6. Execute ‘build.bat all’. You should get something like this:

Build

prefuse and Netbeans: Build the jarfiles

7. Start Netbeans and create a new project (New, Choose project, Java, Java Application). Lets call it PrefuseDemo.

8. Open the project properties (right click on the project name in the project explorer) and select properties. Go to the libraries sectio and add prefuse.jar and demo.jar (required for the sample code). You find these files in the folder ‘build’ created by our build.bat.

9. Now you change the packagename (with the initial created Main.Java if selected) to prefusedemo.

10. In the build folder you also find a src folder with various sample java code. For this tutorial I took GraphView.java.

11. Create a new javaclass in the prefuse package with the name GraphView.

12. Copy the complete sourcecode from GraphView.java into it and replace the basic skeleton.

13. Fix the package name to package prefusedemo;

14. You can delete the Main.java if NB created it for you.

15. Build the project.

16. Right click onGraphView.java and select Run File. Finished ! You should see this:

t200901300014

prefuse and Netbeans: Run the demo


Remarks:
1. The other files (demos that come with the prefuse package) you can create the same way and add them into your demo application.
2. I tried to import the whole prefuse source folder into Netbeans via Import, but it didnt work.

Conclusion:
Now we got started, lets move on to understand the prefuse concept and adapt some of the samples to our own applications or create new ones from the scratch ! Stay tuned for more prefuse !





SUN Techdays Singapore 2009 résumé

23 01 2009

2 days packed with sessions, demos and hands-on labs ! It was a SUN event, and SUN folks also learned to celebrate themselves with loud music and big-bang entertaining keynotes. Fine with me, part of the show. Obviously everything evolved around SUN technology and everything they support.

The products, technology and key/buzzwords were clearly:

  • Cloudcomputing
  • Open Source
  • Open Solaris
  • Virtual Box
  • Netbeans
  • Glassfish
  • MySQL
  • JavaFX

Feedback:
Most of the sessions were useful, or at least you got an overview of some new stuff or ideas.The hands-on labs were not as good because the trainer(s) needed to spend some of the time helping people to install Netbeans or xyz plugins (which is an audience problem) and beyond that is not useful to let the attending folks read the instructions from a zip-file and DIY while the trainer is available for questions (in Singapore hardly anyone ask anything).
It is always good for networking (and free food) to join these kind of conferences. Btw, the conference fee was 80.- SGD for 2 days (hands-on lab extra 50.- SGD each)

My highlights:

  • Simon Ritter (blog) presenting Wii Remote with JavaFX and SunSpots Technology (link)
  • Carol MacDonald (blog) on JMaki, Comet, Grizzly and EJB (Spring vs. Seam vs.  plain JPA)

Conclusion:

  • I will join the next TechDays.
  • I am installing OpenSolaris right now on a notebook (after checking with device detection tool, link).
  • I will continue to use the SUN (related) products that I already use (Netbeans, Glassfish, MySQL, Virtual Box)




JUG (Java User Group) Singapore

11 01 2009

OK. After digging further I found a group… not dead, just not as active (at least online).

More info at Google Groups. Will add more info after joining them and see whats going on.





Tutorial: Starting with Glassfish and JMS (Part 2)

9 01 2009

Today we proceed with last weeks JMS tutorial and create a standalone java application that sends a message to a topic.

It puzzles me to have a client application that I need to start “from within”. Lets find out how an application looks like that can run by itself, connect to a JNDI server and sends a message to topic. The key information I took from this discussion (link, Thanks to Foli and TravelEntity) at forums.sun.com.

Using: Netbeans 6.5 and a local Glassfish V2

1. Lets create a standard SE java project. We call it “JMSClient”

tut09010005_new_java_application

JMSClient: New Java SE project

2. Import the necessary libraries

Applicationserver JNDI Lookup
/lib/appserv-rt.jar
/lib/appserv-admin.jar
/lib/javaee.jar
/lib/j2ee.jar

Client Lib
/imq/lib/jms.jar
/imq/lib/imq.jar
/imq/lib/imqutil.jar
/lib/install/applications/jmsra/jmsra.jar

(You find them in your glassfish home directory)

Libraries

JMSClient: Libraries

3. The complete source


package jmsclient;

import java.util.Hashtable;
import java.util.Queue;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.Topic;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class Main {

    public static void main(String[] args) {

        Context jndiContext = null;
        ConnectionFactory connectionFactory = null;
        Connection connection = null;
        Session session = null;
        // ---- Same sample with a queue ----
        // Queue queue = null;
        Topic topic = null;
        MessageProducer messageProducer = null;
        MapMessage message = null;

        Hashtable properties = new Hashtable(2);
        properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.appserv.naming.S1ASCtxFactory");
        properties.put(Context.PROVIDER_URL, "iiop://localhost:3700");

        try {
            jndiContext = new InitialContext(properties);
            connectionFactory = (ConnectionFactory)jndiContext.lookup("jms/ConnectionFactory");
            // ---- Same sample with a queue ----
            //queue = (Queue)jndiContext.lookup("jms/Queue");
            topic = (Topic)jndiContext.lookup("jms/Topic");

            connection = connectionFactory.createConnection();
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            // ---- Same sample with a queue ----
            //messageProducer = session.createProducer(queue);
            messageProducer = session.createProducer(topic);
            message = session.createMapMessage();

            // ---- Preparing Mapped Message ----
            message.setString("lastname", "Myer");
            message.setString("firstname", "Fred");
            message.setString("id", "0200");

            messageProducer.send(message);

            connection.close();

        } catch (NamingException e) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);
        }
        catch (JMSException e) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);
        }
        finally {
            System.out.println("ENDED.");
            System.exit(0);
        }
    }
}

Remarks:

  • The tutorial is looking for a local server. Change (Context.PROVIDER_URL, “iiop://localhost:3700″) to the relevant server and port info.
  • We use a topic (publish/subscribe) in this sample. If you want to use a queue instead, change to the lines which are commented out and remove the topic related lines.




JUG (Java User Group) Singapore

7 01 2009

I was recently ranting about a missing Singapore Java User Group. There is some information about previous groups but they appear dead. I try to start a new one… I considered to use meetup.com but I am not really willing to pay money for this. Sorry.
I am not a Java Guru or expert, but that wont stop me to organize something.

Netbeans Wiki Info

The SUN Techdays (20.22 Jan 2009) would be a good starting point.





Tutorial: Starting with Glassfish and JMS

3 01 2009

Despite tons of material, downloads and websites on JAVA enterprise applications, tools and features, there are few sources only for “Let’s get started” styled tutorials. The Netbeans tutorial is often the best starting point (link).

I was reading about the background of JMS, some of the material is of a very theoretical nature and I tried to find some simple sample to get my hands dirty. A good short article on JMS in the glassfish context you can find at java.net (link)

This tutorial describes the steps to get a most simple messaging application up and running implementing a one-to-many communication using topics, also called publish-subscribe. A enterprise client creates a message put it on a topic and a message-driven bean (MDB) retrieves the message.

Using: Netbeans 6.5 with installed Glassfish V2.

1. Creating a new JAVA EE project.

MyJMS Project

MyJMS Project: New Project

2. We call it MyJMS. Disable the web-application and enable application-client

My

MyJMS Project: New EE Application

3. We will have a project window with 2 subprojects for the EJB and the application client.

d

MyJMS Project

4. Before we start with the coding of the EJB and the client, we configure the applicationserver. Open the admin console via right click on the application server under services (Start the server first, if not done yet). You remember the default admin password for glassfish ? “adminadmin”.You better change if your box is open to outside world.

tut09010003_

MyJMS: View Admin Console

In the admin console we create the ressources for the JMS topic.

tut09010006_

MyJMS: Add Resources

Create a destination resource with JNDI name “jms/topic” and Resource type “javax.jms.topic” (rest default settings).
Create a connection factory with the JNDI name “jms/TopicFactory” (rest default settings, but remove username and password).

Read the rest of this entry »