Running NetBeans developed Java JAR on OS/X

I ran into some issues yesterday when trying to deploy an application that I developed in NetBeans.  I’m using the forms designer feature of NetBeans 6.9 which utilizes Swing controls.  Its very nice I might add, however I did receive a warning message that Swing will no longer be updated going forward, so I’m going to have to consider doing the next one in the “Application Platform” that is recommended.

There were a couple of things I needed to do to get this application to work on OS/X.  First is to install JDK1.5 Update 14.  Apple has their own version of Java, that they distribute and maintain.  As of this blog post, JRE1.5 R10, is the highest it goes.  So we will need to compile against 1.5 instead of 1.6 that is the default JDK that gets installed with NetBeans 6.9. 

I downloaded JDK1.5 by searching for it on Google.  After installing it, you need to explicitly add it to your Platforms in NetBeans.  See below.

On the NetBeans menubar click Tools, then Java Platforms.  A dialog window will appear. 

image

Click Add Platform… Browse to your Program Files directory on Windows and then Java.  (usually C:\Program Files\Java).  There you should see the JDK1.5 folder.

image

Select it and click Next >.  On the next screen, give it a name and target the source.  You may want the Javadoc too, which you need to download from Sun’s site.

image

Now you’ll be able to compile against JDK1.5.  The next step is to ensure that your compiling against the correct Swing implementation.  In the form designer select one of your forms, as seen below.  Notice the properties window, and the Layout Generation Style property.

image

Make sure that it says Swing Layout Extensions Library and NOT Standard Java 6 Code. 

The final difficulty I had was with reading a text file.  Line delimiter characters vary from platform to platform.  I had hard code to parse on “\r\n”.  A safer way to do this is to use: System.getProperty("line.separator").  A much safer way to code up.

 

Technorati Tags: ,,
07.21.2010 20:46 by Danny Gershman | Comments (0) | Permalink