javablogspot

Just another WordPress.com weblog

Posts Tagged ‘NetBeans’

NetBeans Platform Enables Intelligent Homes!

Posted by damuchinni on March 24, 2009

Marek Kliś works as a software developer for MCD Electronics, a company in Żywiec, Poland, which produces electronic equipment. It is his responsibility to develop software for the configuration of this equipment and for the visualization of the related functionality, more info about which can be found here. He also develops software for the company’s management system.

In addition, Marek is a fan of Java and its related technologies. He’s an active member of the Polish JUG and the Silesia JUG, where a recent NetBeans Platform Certified Training was held.
You’ve been using the NetBeans Platform at work. How did that happen?

Well, I needed to make software to configure the building management system worked out by my company. In the beginning, I started with Swing without any framework. However, it took too much time to create the user interface and the result was not satisfactory because the application was not friendly to the end user.

So then I started to look around for a framework that could help me. I came up with two possibilities: Eclipse RCP and NetBeans Platform. After a few tests I chose the NetBeans Platform, which seemed to be the right solution for my Swing application.
What exactly is the application you’re developing?

The application is needed for configuring the system that controls the lighting, heating, and opening/closing of gates in houses. In the building sector, a system of this kind is known as an “intelligent home”. Our goal is to create a multipurpose system available for home management.

Therefore, the application has to be easy to use and intuitive to install. It also needs to be very simple to maintain. Even the most complicated system functions must be simple to configure.
What are the main features and highlights of the application?

*

The application has its own project type. A “project” consists of a database and some specific XML files that can be visualized and modified graphically by user, thanks to the Visual Library’s widgets. The database contains the complete system’s configuration.
*

The user can create a separate project for each installation.
*

Every installation is different. It can consist of up to 640 specific logical modules. Each module has to be configured and the user must configure the connections between modules. The application helps to do this by means of several wizards.
*

The application helps to restore system configurations if/when the hardware crashes.

How is the NetBeans Platform helping?

Thanks to the NetBeans Platform, I was able to concentrate on the application logic, since the NetBeans Platform made the various GUI mechanisms available to me.

For example, I found the Visual Library very helpful for my purposes. The Visual Library provides widgets that helped me to illustrate the connections between the system elements in a very simple way. For this reason, the system configuration has now become very easy and fast:

Another useful part of the NetBeans Platform is its Wizard API. The Wizard API helped me create a set of wizards that make some operations much easier for the end user:

What are your favorite features of the NetBeans Platform?

The Visual Library API is one of the coolest libraries on the NetBeans Platform. It enables you to illustrate graphically the different data sets and data schemes in a very simple way.

Another favorite feature for me is the fact that NetBeans Platform is built on Swing!

The third and most important NetBeans Platform feature is… that it is an open source project! I can look at the NetBeans Platform source code and see how the NetBeans engineers use the various platform libraries. That’s very helpful.
What could be better?

I encountered difficulties regarding refactoring. Not every change of class names causes a related change in the XML configuration files, i.e., the layer XML file.

In my opinion, it would be great to have a tool for including automatically all the necessary libraries needed in the Project Properties dialog, for the NetBeans Module Suite project type. For example, if I include a module that depends on 10 others, I currently need to find and explicitly include them manually one by one! NetBeans IDE informs only about the first dependency, and after resolving it, NetBeans IDE informs about the next one, and so on, which is a bit cumbersome.
Can you give a few tips and tricks for getting started with the NetBeans Platform?

*

Start at the NetBeans Platform homepage. There are many tutorials and a lot of documentation that can help you to get acquainted with the NetBeans Platform.
*

Next, take a look at screencast series “Top 10 NetBeans APIs”.
*

I recommend to download the NetBeans IDE source, where you can find a ready solution for most problems.
*

Subscribe to the mail lists dev@openide.netbeans.org and users@graph.netbeans.org, if you want to use the Visual Library. Don’t be afraid to ask questions if you don’t find answers in the archive!
*

Look at planetnetbeans.org. PlanetNetBeans is an aggregator of NetBeans-related musings from all over the blogosphere.

When will the application go into production? What are the main features you will add in the future?

The application, as a Beta, has just become available. The application needs to be extended with a reporting system. In the future, we plan to add a module that will show system state in real time.
Any other thoughts to share?

I think that the NetBeans Platform is a perfect solution for building modular desktop applications.

Let’s concentrate on application logic and don’t try to solve problems that have already been solved by NetBeans engineers, such as modularity and a window system.

Finally, I’d like to thank the Polish Team for translating the NetBeans Platform into Polish. It made my work a lot easier because one of the requirements was that it had to be in Polish!

Posted in IDEs | Tagged: | 1 Comment »

Java RTS NetBeans Module 1.0 Getting Started Guide

Posted by damuchinni on February 24, 2009

This document provides the minimum information required for installing and using the Sun JavaTM Real-Time System (Java RTS) NetBeansTM module.

Important Note: This a preliminary version of the module.

The document contains the following sections:

Introduction to Sun Java RTS This section presents an overview of Java RTS.
The Java RTS NetBeans Module This section presents the features provided by the Java RTS NetBeans module.
Installation This section explains the installation of the Java RTS NetBeans module.
Usage This section describes how to use the Java RTS NetBeans module.
Known Limitations This section points out the known limitations of this distribution.
Introduction to Sun Java RTS
The Sun Java Real-Time System is the first commercial implementation by Sun Microsystems of JSR-1, the Real-Time Specification for Java (RTSJ), which combines industrial-strength real-time functionality with the usability, abstraction, and standards-based advantages of Java technology. Java RTS supports hard real-time, soft real-time, and non-real-time functionality concurrently within a single Java Virtual Machine (JVMTM).

Java RTS Features and Benefits
New Real-Time Threads, Scheduling, and Synchronization
The RTSJ introduces the concept of two new threads: real-time threads and no-heap real-time threads. (A no-heap real-time thread cannot be interrupted by garbage collection.) These threads offer more precise scheduling than standard Java threads. They have 28 levels of priority and, unlike standard Java threads, their priority is strictly enforced.

Real-time threads are synchronized and are not subject to so-called priority inversion situations, where a lower priority thread has a block on a resource needed by a higher priority thread and thus prevents the higher priority thread from running.

New Memory Management Schemes
The RTSJ defines two new types of memory areas that allow real-time applications to avoid unpredictable delays commonly caused by traditional garbage collectors:

Immortal memory holds objects without destroying them, except when the program ends. This means that objects created in immortal memory must be carefully allocated and managed.
Scoped memory is used only while a process works within a particular section, or scope, of the program, such as in a method. Objects are automatically destroyed when the process leaves the scope. This is a useful feature akin to garbage collection in that discrete creation and deletion is not required as in the immortal memory case. However, the process must exit the scope to ensure that the memory is reclaimed.
Immortal memory and scoped memory are not garbage collected, so using them avoids problems of garbage collection (GC) interference.

Asynchronous Events Handling & Asynchronous Transfer of Control
The RTSJ provides two mechanisms for asynchronous communication: asynchronous event handling, and asynchronous transfer of control.

Asynchronous event handlers deal with external events (known as “happenings”) which can occur outside the JVM. The RTSJ is unique in that it allows developers to schedule the response to asynchronous events in order to avoid disrupting the temporal integrity of the rest of the real-time application.

Asynchronous Transfer of Control (ATC) provides a carefully controlled way for one thread to interrupt another thread in a safe manner.

Time & Timers
The RTSJ specifies several ways to specify high-resolution (nanosecond accuracy) time, including absolute time and relative time.

Direct Access to Physical Memory
While maintaining security protections, the RTSJ allows direct access to physical memory. This means that device drivers can be created that are written entirely in the Java language. Previously, Java applications had to link to native code to communicate directly with the hardware.

The Sun Java RTS product is available through Sun OEM Sales. Contact them at: OEM_Technology_telesales@sun.com or by telephone at +1-800-786-0404, Prompt 1, Prompt 3.

The Java RTS NetBeans Module
The Java RTS NetBeans module adds real-time application development support for the NetBeans 5.0 release. The only difference in the development process of an application with the Java RTS NetBeans module compared to a regular NetBeans 5.0 environment is the cross-platform development, namely the remote deployment and remote execution on a target where the Sun Java Real-Time System has been installed.

Unchanged Features in the NetBeans Module
The basic features in the NetBeans integrated development environment (IDE) remain unchanged. For example, the following features remain identical to a standard Java SE application:

Code editing and completion: While editing the code, in the middle of typing a Java RTS API class or method name, the developer can ask the system to provide a list of names to complete the word being typed. The developer can then choose a possible completion from this list, and the corresponding output from the JavadocTM tool is displayed in HTML format.
Build and runtime process: There is no change in this process compared with the standard Java SE application development.
Additional Features in the NetBeans Module
To support the development of a Java RTS application on a remote target, the following features have been added to the environment:

Creation of a new project category called Java Real-Time project in addition to the standard list. The developer chooses this project in order to develop a Java RTS application. This feature is provided in the New Project wizard.
Cross-platform development features. The Java Platform Manager wizard GUI has been enriched with a new platform category called Real Time Java, which allows the developer to specify remote deployment and execution parameters. See the Usage section below for more information.
Application deployment and execution profiles. The user can record, save, import from the filesystem, and export to the filesystem various remote deployment and execution parameters, for example, the Java RTS remote target on which the application should run. See the Usage section below for more information.
Installation
The Java RTS NetBeans module is actually a suite of three modules, each of which supports a dedicated set of features.

LocalRTSJStubs: This is a bridge module that encapsulates the necessary data for code editing, completion, build time (jar and javadoc files), and also for deployment and runtime (script files).
MackinacPlatform: This module contains all the additions and changes to the NetBeans platform application framework to support real-time development (new wizards, new project categories, and so forth).
Projects: This module contains the Java RTS project templates and additional code to support the new wizards.
To install the module suite, download and unzip the modules from this location. Then choose Tools | Update Center, select Install Manually Downloaded Modules, and click Next. Specify the location of the modules and complete the wizard. Important Note: You must install all three modules to get a complete and functional Java RTS NetBeans module installation.

Requirements
The module has been tested on the Solaris 10 Operating System, and on the Windows XP Professional SP2 and Linux platforms. Note that MacOS is not supported at this point. The system requirements to install and run the module are as follows:

NetBeans 5.0
JDK 5.0
8 MB of available space to install the modules
Usage
The development process for a Java RTS application is the same as for a Java SE application. It is performed with the following steps:

Create a Java RTS project using the modified New Project wizard.
Specify remote deployment and execution through the modified Java Platform Manager wizard.
Build and execute.
Stop the application.
Creating a Java RTS Project
The modified New Project wizard has a new Real Time Java Projects folder in the Categories panel. When this is selected, the list of available projects in the right panel provides a Real Time Java Project item. Select this subcategory of project.

When the Real Time Java Project item has been selected, click the Next button and follow the remaining standard procedure for a NetBeans project in order to create the Java RTS project.

Specifying Remote Deployment and Execution
You need to choose Tools | Java Platform Manager, to invoke the Java Platform Manager wizard, which has been enhanced to support remote deployment and execution of a built Java RTS application. The wizard provides a new Real Time Java 1.0 folder in the platform panel that the Java RTS developer selects. The developer specifies the deployment execution process parameters through the profile. Multiple profiles can be created and used at any time. The deployment and execution protocols used are rcp and rsh, respectively.

Below are the items that the user specifies:

Host Name: The remote machine on which Java RTS is installed (or the IP address of your remote target).
User Name: The user login name (configure the correct user rights for the Java RTS installation on the remote target).
Remote JDK Location: The location of the Java RTS installation on the remote target (for example, /opt/SUNWrtjv).
Remote JAR Location: The location on the remote machine where the Java RTS application JAR file is to be copied (for example, /tmp)
JVM Arguments: A text field to specify Java VM arguments to be used at runtime.
When all these parameters have been specified, click the Close button at the bottom right of the wizard.

Profiles: The Java Platform Manager wizard supports the notion of profiles. A profile records a set of deployment and execution parameters for future reuse. The developer can use the Profile combobox and the Add, Remove, Import, and Export buttons to save and manage various deployment and execution profiles.

Building and Executing
Build time: Use the standard contextual menu items named Build Project, Clean and Build Project, and Clean Project. They work in the same way as for a Java SE application.
Run time: Use the standard contextual menu item named Run Project to deploy and run your Java RTS application remotely. Remote deployment is done first, followed by remote execution. The parameters used are those specified through the modified Java Platform Manager wizard.
Stopping the Application
This preliminary release of the module version does not yet integrate a proper way of stopping the application on the remote target. If the application does not terminate by itself, you have to log onto the remote target and stop the application by killing the corresponding VM process. Note that it may then take a few seconds for your NetBeans project to be stopped.

There is however a work-around for stopping the application which may be used when there is only one instance of a Java VM running on the remote target: add the following Ant target to the build.xml file of your Java RTS project and add a target shortcut to your NetBeans environment (use the Create Shortcut contextual menu on this stop Ant target).

Known Limitations
The current version of the Java RTS module has the following known limitations:

The “Java Real Time Class Library” project subcategory in the New Project wizard is not yet supported.
Local deployment and execution is not yet supported.
Debugging or profiling the application is not yet supported.
Support for stopping the application running on a remote target is not yet properly integrated in the IDE.
Deployment and execution protocols are not yet customizable.
On Windows XP, in the argument list passed to the remote Java RTS VM, that is, in the “JVM Arguments” text field of the Java Platform Manager wizard, any ‘=’ character must be prefixed by the string “##”. In other words, “=” string must be specified as “##=”. For example, “-DMyProperty=foo” in the VM argument line would be expressed as “-DMyProperty##=foo”.

Posted in IDEs | Tagged: , | 1 Comment »

3, 2009 Running Groovy on the NetBeans Platform

Posted by damuchinni on February 14, 2009

Here’s a Groovy POJO:

package org.my.app

public class DemoPojo {

    def foo

}

And here’s my ModuleInstall class (which is a NetBeans module’s lifecycle manager), which uses its restored() method to instantiate the POJO, set the variable, and then print out the variable. Oh, by the way, the class below is, just like the above, a Groovy class. The thing to notice is that I defined no getter/setter in the POJO above, because Groovy simply assumes I have them, and that there are no semi-colons at the end of the statements at all (thanks again Groovy).

package org.my.app

import org.openide.modules.ModuleInstall as MI

public class Installer extends MI {

    @Override
    public void restored() {

        for(int i = 0; i < 10; i++) {
            DemoPojo dp = new DemoPojo()
            dp.setFoo(i)
            println("Number: " + dp.getFoo())
        }

    }

}

Also, the “println” statement comes from Groovy, without my needing to import the class. Look also at the abbreviation for my imported class, which I can then refer to in that way in my class signature (and anywhere else). In fact, I could use any Groovy constructs at all now.

So the above two are in a module. The ModuleInstall class is registered in the Manifest, just like any other ModuleInstall class, because after compilation the Groovy class becomes a Java class. At that point, there’s no difference anymore.

To make all of the above possible, add the following to your module’s build.xml file:

<taskdef name="groovyc"
     classpath="ext/groovy-all.jar"
     classname="org.codehaus.groovy.ant.Groovyc"/>

<target name="netbeans-extra">
    <groovyc srcdir="${src.dir}" destdir="${build.classes.dir}">
        <classpath refid="cp"/>
    </groovyc>
    <jarwithmoduleattributes jarfile="${cluster}/${module.jar}"
           compress="${build.package.compress}" index="${build.package.index}"
           manifest="${manifest.mf}" stamp="${cluster}/.lastModified">
        <fileset dir="${build.classes.dir}"/>
    </jarwithmoduleattributes>
</target>

So, after the Groovy compiler does its thing, the module’s JAR is recreated, using the output from the Groovy compiler. Note that, as indicated above, you need a folder in your module named “ext”, containing “groovy-all.jar”. You also need to put your module in a suite and set a dependency on a library wrapper module that contains “groovy-all.jar”.

Here’s the Projects view on my module, isn’t it cool to see only Groovy classes there?

Then you’ve got everything you need to run Groovy on the NetBeans Platform. Now excuse me while I go and create some file templates for Groovy versions of TopComponents, Actions, and so on…

Posted in IDEs | Tagged: | 2 Comments »

Telling NetBeans IDE Which JDK to Use

Posted by damuchinni on February 13, 2009

A customer has filed a bug about the Generator menu item not working for NetBeans Rails projects if the IDE is using version 6u12 of the Java Development Kit (JDK) software.

Not knowing how to tell the IDE to use a different JDK, the user reinstalled the NetBeans software.

If you don’t know already, there is no need to go to such lengths. Here are two ways to tell the IDE which JDK to use.

  • Specify the JDK in the startup command. Modify the command that starts the IDE to include the --jdkhome option pointing to the desired JDK. For example:

    netbeans-install-dir/bin/netbeans.exe --jdkhome "%JAVA_HOME%"

    The above example uses the %JAVA_HOME% environment variable, which is set to C:Program FilesJavajdk1.6.0_10, but you can just supply in the path instead. If it has spaces in it, put the path in quotes (that’s why the environment variable is in quotes).

  • Specify the desired JDK in the netbeans.conf file. Open the netbeans-install-dir/etc/netbeans.conf file, look for the following option and set it to point to the desired JDK. You might need to unremark the setting.

    netbeans_jdkhome="path-to-jdk"

  • If you are not able to modify the netbeans.conf file because you are sharing the installation or you don’t have permission, you can instead create an etc folder in your NetBeans userdir and put a netbeans.conf file in the etc folder. You only need to put in the options that you want to override. For more information see the How do I make my custom startup parameters permanent? FAQ.

Posted in IDEs, Java | Tagged: | Leave a Comment »

NetBeans Lookups Explained!

Posted by damuchinni on February 12, 2009

Lookups are one of the most important parts of the NetBeans Platform. They’re used almost everywhere and most of the time when you ask something on a mailing list the answer is “Use Lookups!”.

Posted in IDEs, Java | Tagged: | Leave a Comment »