Google Protocol Buffers Netbeans Plugin on Mac os X

Posted by Ingmar Hendriks on 25 June 2009

Recently I have been researching google buffers protocol as a way of communication in one of my projects. I found a very interesting plugin for the netbeans platform that allowed me and my team mates to use the protocol buffers. However when we started working with it we struck a few bumps.

Installing the plugin is quite easy:

Install Protocol Buffers: http://code.google.com/p/protobuf/downloads/list. Go to the Plugin manager settings tab, Click add and enter name: "Protobuf plugin update center" and URL: http://protobuf-netbeans-plugin.googlecode.com/svn/distr/latest_stable/updates.xml You can then install the plugins using the plugin manager.

The Bug

However after the plugins are installed on a mac OS/X platform the problems begin. Before you can use the plugin you need to select the protoc executable. This is done in the options/preferences window in netbeans. When you try to open the protocol buffers windows nothing happens or at-least it looks like nothing happens. On the lower right side of the screen an icon appears. This is an netbeans bug report which contains the following error:

java.lang.NoClassDefFoundError: javax/swing/GroupLayout at pl.waw.tabor.netbeans.protobuf.configuration.ProtocolBuffersPanel .initComponents(ProtocolBuffersPanel.java:47)

This error means that java doesn't know what GroupLayout is. The reason java doesn't know GroupLayout is because on a mac OS/X system the Java 1.5 JDK is installed as default. We need JDK 1.6 to be able to use the GroupLayout.

The Fix

Luckily 1.6 is most likely already on your mac OS/X system (if you have an up to date system) however it is not set as the default for either your system and for netbeans. First we explore how we can set 1.6 as the system default:

Run /Applications/Utilities/Java/Java Preferences And drag the Java SE 6 to the top of the list.
Now all the java applications run with JDK 1.6. But we still need to set Netbeans to work with JDK 1.6.

Locate the NetBeans config file, typically located at “/Applications/NetBeans/NetBeans 6.5.app/Contents/Resources/NetBeans/etc/netbeans.conf” and open the file in your favorite editor.
Set the “netbeans_jdkhome” parameter to the JDK 1.6 home directory (ie. netbeans_jdkhome=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home).
Now you can start netbeans with the 1.6 JDK Now that we have JDK 1.6 we can use the Google Buffers Protocol as if we never encountered the problem.

Tested under Netbeans IDE 6.5 an google protocol buffer plugin 1.0.3

Sources: http://code.google.com/p/protobuf-netbeans-plugin/ http://devblog.point2.com/tag/netbeans/