Last updated July 25, 2010 13:26, by Bruce Schubert
Feedicon  

Campbell Prediction System

Developer FAQ (Lessons Learned)

Version 1.6

Bruce Schubert

Revision History

Name Date Reason for Changes Version
Bruce Schubert July 25, 2010 Added module signing instructions 1.6

Introduction

Purpose

The purpose of this document to improve software development productivity by preventing the same problems from being solved over and over again. This document serves as a FAQ for development issues pertaining the technologies used in the Campbell Prediction System (CPS).

Scope

The scope of this document is primarily NetBeans, NetBeans Rich Client Platform (RCP), JNLP, OpenGL, JOGL, and the NASA WorldWind Java SDK. However, additional tips and tricks related to the Project Kenai site are included.

JNLP

JNLP Error - "unable to load resource"

Problem -- I have gotten the following error:

 com.sun.deploy.net.FailedDownloadException: Unable to load resource:
 http://kenai.com/projects/rsaska/downloads/converter/launch.jnlp

Solution -- Based on my experience with JNLP and the CPS project, the problem lies in the URL within the .jnlp file. The URL will be different than it appears in your browser when viewing your Project Kenai downloads folder. The correct URL is in this form:

 http://kenai.com/downloads/<project name>

whereas the URL displayed in your browser is in this form:

 http://kenai.com/projects/<project name>/downloads


Correct JNLP codebase entry in launch.jnlp:

 <jnlp codebase="http://kenai.com/downloads/rsaska" href="launch.jnlp" spec="1.0+">

Incorrect JNLP:

 <jnlp codebase="http://kenai.com/projects/rsaska/downloads/" href="launch.jnlp" spec="1.0+">

Self-Signing jar files with NetBeans Web Start

Problem -- My NetBeans Web Start project was self-signing my jar files with a new and different certificate on each build. Thus, I had to upload ALL of the jar files each time I made a change. All the files must share the same certificate for Web Start to work.

Solution -- Configure NetBeans to use my own keystore. Essentially, this requires the following entries be added to your nbproject/private/private.properties file or nbproject/project.properties file. Like this:

 jnlp.signjar.keystore=<location of the keystore on disk>
 jnlp.signjar.storepass=<valid store password>
 jnlp.signjar.keypass=<valid key password>
 jnlp.signjar.alias=<valid alias>

I chose to use the nbproject/private/private.properties file to prevent the "passwords" from being uploaded into svn (svn ignores my private folder).

I found the following NetBeans Wiki article very valuable: FaqOwnKeystoreForWebStart

NetBeans - General Notes

This section contains notes and discoveries relative to NetBeans IDE.

Properties which may be defined in project.properties

Issue: Where can I find out what properties NetBeans uses, or are available to use in my project / application?

Solution: Read the README file in the NetBeans 6.8/harness folder. It has an extensive list of properties defined about midway in the document.

Easily add custom or canned license and copyright information to your source files

Issue: How do I add license and copyright headers to my source files without editing all the source code templates?

Solution: Set the project.license property in your project.properties file to one of the licenses found in Tools | Templates | Licenses folder. Note: The property value must be stripped of "license-" prefix and the ".txt" suffix.

For example, here's how to include the "license-gpl20.txt" license file (included in NetBeans 6.8):

 project.license=gpl20

Note: You can add or customize the license templates. I prefer this solution over editing the source code templates because: its easier; it survives the migration from one version of NetBeans to another; and its portable to different users/computers.

NetBeans - Rich Client Platform (RCP) Notes

This section contains notes and discoveries relative to NetBeans RCP applications. Hopefully, these discoveries and implementation details can aid in development of other RCP applications.

Supplying command line arguments in your development environment

Issue: How do I pass command-line arguments to my application?

Solution: Add the run.args.extra property to you suite's project.properties file and supply the desired runtime arguments, for example, here's how to specify the look and feel, system properties and JVM:

 # for development purposes you may wish to append: -J-Dnetbeans.logger.console=true -J-ea
 # for anti-aliased controls add: J-Dswing.aatext=true
 # --laf options :
 # javax.swing.plaf.metal.MetalLookAndFeel (Java Cross Platform)
 # com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel (modern Synth-based) run.args.extra=--laf javax.swing.plaf.metal.MetalLookAndFeel J-Dswing.aatext=true -J-Xms64m -J-Xmx512M 

Supplying command line arguments to the launcher in your distributed application

Issue: How do I pass command-line arguments to my application's launcher?

Solution: In your distributed application (running outside the NetBeans IDE), you must pass your arguments into the application launcher. You need to override the default app.conf file found in the NetBeans 6.7.1/harness/etc folder.

I accomplished this by creating a custom app.conf file within my project's folder hierarchy and then I modified the suite.xml build script to use my custom file instead of the default ${harness.dir}/etc/app.conf file, and I added a property my project.properties file specifying the location of the custom app.conf file

For example, my customized app.conf file contains the following line
 default_options="--branding ${branding.token} -J-Xmx512M -J-Dsun.java2d.noddraw=true"
And my customized suite.xml contains the following lines (I simply prepended my. to the harness.dir property)
 <!-- Copy in a custom app.conf file (instead of the default); note the use of "my.harness.dir" property -->
 < copy file="${my.harness.dir}/etc/app.conf" tofile="${build.launcher.dir}/etc/${app.name}.conf">
And finally, my RCP suite's project.properties contains the following lines
  # my.harness.dir is used in the suite.xml build script and it contains a customized app.conf file
  my.harness.dir=harness

RCP Implementation Details for WorldWind and JOGL

Issue: Screen flicker or blank canvas on NASA WorldWind OpenGL Canvas (running within NetBeans IDE) on Windows OS.

Solution: Add the following line to the RCP Suite's project.properties file. The run.args.extra arguments are used when your RCP application is launched from within the NetBeans IDE. The resolution to the screen flicker problem is the -Dsun.java2d.noddraw=true statement which defeats the Java2D's DirectDraw pipeline and forces it to use its GDI pipelne. More information about this issue can be found on the JOGL User Guide.

 run.args.extra=-J-Xmx512M -J-Dsun.java2d.noddraw=true


Issue: Screen flicker or blank canvas on NASA WorldWind OpenGL Canvas in distributed application on Windows OS.

Solution: In your distributed application (running outside the NetBeans IDE), you must pass in the aforementioned noddraw argument to the application launcher. You need to override the default app.conf file found in the NetBeans 6.7.1/harness/etc folder. I accomplished this by creating a custom app.conf file within my project's folder hierarchy and then I modified the suite.xml build script to use my custom file instead of the ${harness.dir}/etc/app.conf file.

My customized app.conf file contains the following line
 default_options="--branding ${branding.token} -J-Xmx512M -J-Dsun.java2d.noddraw=true"
My customized suite.xml contains the following lines (I simply prepended my. to the harness.dir property)
 <!-- Using a custom app.conf file; note use of "my.harness.dir" property -->
 < copy file="${my.harness.dir}/etc/app.conf" tofile="${build.launcher.dir}/etc/${app.name}.conf">
My RCP suite's project.properties contains the following line
  # my.harness.dir is used in the suite.xml build script and points to a customized app.conf file
  my.harness.dir=harness

Adding JOGL support via the NetBeans OpenGL-Pack

Issue: How do I add the NetBeans OpenGL Pack nbm modules to my RCP application to get the native JOGL libraries?

Solution: Augmented installation instructions:

  1. Download the NetBeans OpenGL Pack from the plugin portal and extract the archive
  2. Start NetBeans and open the Plugin Manager (Tools->Plugins)
  3. Enable the Force install into shared directories checkbox on the Settings page
  4. Add all modules (.nbm files) to the Downloaded plugins list and press Install
  5. The installation wizard will guide you now for the rest of the installation

By using the shared directories option, the OpenGL modules will appear in the extras node within your application's list of available libraries (Project Properties > Libraries > Platform Modules). For basic JOGL support in your RCP application, add the following modules to your RCP-suite project:

  1. JOGL runtime libraries
  2. GlueGen runtime libraries
  3. Native library support
  4. JAXB Library

Then add the JOGL and GlueGen dependencies to your module projects that require compile time or runtime OpenGL support (Project Properties > Libraries > Module Dependencies).

Internal versus External Web Browser

Issue: The View > Web Browser option invokes an internal Swing web browser instead of an external browser; also, web browser options are not available in the Tools > Options > General Settings page.

Solution: In the Project Properties > Libraries section, add the External HMTL Browser platform module (and its dependencies) from the ide11 or ide12 node. After a clean and build, the external web browser will be invoked from the View > Web Browser menu item. Also, the Tools > Options > General Settings will now contain settings for specifying the default browser.

Use Branding to rename built-in menu items

Issue: The built in "View -> IDE Log'" is useful and I want to retain it, but I want rename the "IDE Log" menu item to something more appropriate for my application.

Solution: Use branding to override the built-in Bundle.properties for the "IDE Log" menu item. Here are the steps:

  • Identify the jar file that contains the menu action's Bundle.properties.
    • Explore a module's layer.xml "in context" to get the root name of the menu item. In this case it's org-netbeans-core-actions-LogAction. With this information, I explored the C:\Program Files\NetBeans 6.8 Beta\platform11\modules folder and noted that it contained a org-netbeans-core.jar file.
    • Explore the contents of the jar file to find the Bundle.properties and the property name that needs to be overridden: I found the Bundle.properties in the org/netbeans/core/actions folder
    • Examine the Bundle.properties: I found these entries:
 #LogAction
 MSG_LogTab_name=IDE &Log
 MSG_ShortLogTab_name=IDE Log
  • In the RCP suite branding folder, create a folder hierarchy that mirrors the .jar file name and path to the Bundle.properties file, for example:
 branding\modules\org-netbeans-core.jar\org\netbeans\core\actions
  • Create a Bundle.properties file within this folder and override the settings, in my case I renamed "IDE" to "Application":
 MSG_LogTab_name=Application &Log
 MSG_ShortLogTab_name=Application Log

Adding an Update Center

Issue: How do I distribute and update my NetBeans modules (nbms) over the web in my RCP application?

Solution: Add the "Auto Update UI" to your RCP Suite.

  • add the"Auto Update UI" found in platform11
  • also requires "Auto Update Services"

Then create a new empty module in the suite and then add an Update Center to the module. Use the wizard to generate the Update Center. After a "clean and rebuild, two new menus items will appear in your application. "Tools > Plugins" and "Help > Check for Updates".

However, a java.lang.reflect.InvocationTargetException error is generated when the Update Center plugin is accessed, and, the URL doesn't appear in the Update Center's Settings page. To remedy this error, I had to add the lines referring to the SystemFileSystem attributes to the Update Center module's layer.xml file (note, in the following example I added a space after the "<" to prevent the confusing the Wiki formatting):

 < filesystem>
    < folder name="Services">
        < folder name="AutoupdateType">
            < file name="com_emxsys_uc_update_center.instance">
                <!-- Copied SystemFileSystem. attributes from layer.xml "in context..." thirdparty-update-provider.instance entry -->
                < attr name="SystemFileSystem.localizingBundle" stringvalue="com.emxsys.uc.Bundle"/>
                < attr name="SystemFileSystem.icon" urlvalue="com/emxsys/uc/resources/newUpdates.png"/>
 
                < attr name="displayName" bundlevalue="com.emxsys.uc.Bundle#Services/AutoupdateType/com_emxsys_uc_update_center.instance"/>
                < attr name="enabled" boolvalue="true"/>
                < attr name="instanceCreate" methodvalue="org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogFactory.createUpdateProvider"/>
                < attr name="instanceOf" stringvalue="org.netbeans.spi.autoupdate.UpdateProvider"/>
                < attr name="url_key" stringvalue="com_emxsys_uc_update_center"/>
            </file>
        </folder>
    </folder>
 </filesystem>


NetBeans Module Naming Convention

Issue: When multiple RCP projects are open in NetBeans, the individual module projects are intermixed in the project explorer making it difficult to distinguish my module projects from 3rd party projects that have been opened for review.

Solution: Rename your project's modules with common prefix. This will group them all together in the project explorer window. For example, all of the CPS-Suite's modules are prefixed with "Emxsys -", and some modules are given a categorical prefix, like "Emxsys - Libraries :" which provides an additional sub-sort. These prefixes also work well when working with your library dependencies within your NetBeans platform project -- making it easy to distinguish your modules from others.

To rename a module, simply right-click the module name in the Project Explorer and select "Rename...". Renaming the project folder is optional, and it is not required to realized the benefits of this approach.

I adopted this convention after observing it in Fabrizio Giudici's ForceTen project (http://forceten.kenai.com) .

Self-Signing NetBeans Modules for use in an Update Center

Problem -- When downloading updates from my update center, I'm warned that the plugins are unsigned. Also, I get the following warning in my build output when creating NBMs: Not signing NBM file <filename.nbm>; no stored-key password provided or keystore (<module name>\${keystore}) doesn't exist

Solution -- Configure the NetBeans modules to use a "keystore". I used a common keystore for all the modules in my RCP Suite. This is a 3 step process:

1. Create the keystore. Note: Supply your own text for "secretpassword", also note the use of the suite's "private" folder to prevent checking this file in to source control repositories. You'll find the keytool program in your java/bin folder.

 cd ./path/to/rcp/suite
 keytool -genkey -storepass secretpassword -alias myself -keystore nbproject/private/keystore

2. Then store the password property in the RCP suite's "Per-user NetBeans Platform Config" file in the Project explorer, aka the nbproject/private/platform-private.properties file in the Files explorer:

 storepass=secretpassword

3. Finally, for each module to be signed, I add two properties to the module's nbproject/project.properties file. Like this:

 keystore=../nbproject/private/keystore
 nbm_alias=myself

I found the following NetBeans Wiki article very helpful: DevFaqSignNbm


Project Kenai

Searching Forums

The Forum search currently only searches within the one project. However, you can use Google to search the entire site, including all project forums.

Just add "site:kenai.com" to the search field on Google.com and it will search everything for you. It works pretty well.

--jb The Project Kenai Team

WorldWind

WorldWind OpenGL Canvas Screen Flicker

Issue -- Screen flicker or blank canvas on NASA WorldWind OpenGL Canvas (running within NetBeans IDE) on Windows OS.

Solution -- As mentioned in the JOGL User's Guide, one resolution to a screen flicker problem is the setting the -Dsun.java2d.noddraw=true system property which defeats the Java2D's DirectDraw pipeline and forces it to use its GDI pipeline , for example:

 -Dsun.java2d.noddraw=true 
Also consider using -Dsun.awt.noerasebackground=true in addition noddraw. For example
 -Dsun.awt.noerasebackground=true -Dsun.java2d.noddraw=true

Copyright © 2009-2010 Bruce Schubert, http://www.emxsys.com.

  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2013, Oracle Corporation and/or its affiliates
(revision 20140418.2d69abc)
 
 
Close
loading
Please Confirm
Close