"Never memorize something you can look up", Albert Einstein

Netbeans IDE plugin for Google Protocol Buffers on Mac OS X

Recently I have been researching Google Protocol Buffers 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 teammates 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 we installed the plugin on Mac OS X the problems began. 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. There is an Netbeans bug report with 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 Mac OS X 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 PC (if you have an up to date system) however it is not set as the default for either your system nor for Netbeans.

First set JDK 1.6 as the system default:

  • Run /Applications/Utilities/Java/Java Preferences
  • Drag the Java SE 6 to the top of the list
  • Now all the java applications run with JDK 1.6 if you save

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

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 Protocol Buffer as if we never encountered the problem.

Sources

 


Only members are allowed to post a comment.

Comments

No comments have been placed.