Just another weblog

Archive for the ‘IDEs’ Category

Simple & Useful : Remote debugging with Ant

Posted by damuchinni on March 25, 2009

A Ant java call like :

becomes :

and is ready to be launch and ‘remote debugged’ from a tool like Eclipse IDE.


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

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 and, 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 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 »

unrooted tests of junit 3.4 runner

Posted by damuchinni on March 14, 2009

When using Eclipse 3.3 or above, By the default, the JUnit 4 test runner will be used. In the olden days, with Eclipse 3.0 and JUnit 3.8, user could select a single test method in the Outline view and run just that method. However, when try to do that in Eclipse 3.3 or above. It’s test runner runs all the tests in the class. The results are shown in a tree, and the tests I didn’t ask to be run are all under a node called “Unrooted Tests [Runner: JUnit 4]”.

The problem is because,your class extends TestCase (in Junit 3.8 favior,not use the 4.0 annotation), but eclispe will Using the JUnit 4 runner by the default which causes that unrooted test. if you want to use the old Junit 3.8 runner for your 3.8 testcase. you have change the run configurations manually.

the old Junit 3.8 runner will show up after that:

Posted in IDEs, Junit | Tagged: , , | 1 Comment »

Improve your debugging speed with EVars Eclipse plugin

Posted by damuchinni on March 11, 2009

I have been debugging a lot lately which included open source libraries, closed source web-service engine and parts of closed source application server (WebLogic). During this painful debug-fest I felt a strong need for several features missing in Eclipse (NetBeans as well, for that matter) . Debugging closed applications is a pain beyond imagination, even with IDE integrated decompilers, it takes incredible amount of patience and time to debug.

To improve productivity (or prevent burnout), I jotted down a plugin to export/import live variables, filter variables view with a xpath like expressions etc. The plugin, called ‘evars’, features a small expression interpreter (similar to xpath) which can do a wonderful job of filtering variables on current stackframe. It also allows you to export variables to a file and reload them at a later point.

For the first time, I have attempted to create a screencast to explain its usefulness. You may watch it over here [10mb non-streaming, 1275×860].

I have also created a beta release to see if it finds any interest which you can download it from here [JAR ~800kb] and drop it in dropins folder [Eclipse 3.4+].

Posted in IDEs | Tagged: | Leave a 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: 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.
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.

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
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 »

WebKit4Java (Chromium SWT version) to be released this week

Posted by damuchinni on February 16, 2009

The WebKit4Java SWT browser component we are developing here at Genuitec will be released this week. We have worked through many of the issues with enabling the Chromium WebKit framework to function as a proper SWT browser component and to co-operate within the Eclipse workbench and RCP apps. The challenges have been integrating the Chromium message loop to play nice with that of SWT, focus management and plugin support.

This week’s wrap up work includes settling on a product name (I like WebKit4Java much better than Chromius), basic code cleanup, docs, an improved example app and some unit tests. If all goes well I should be able to roll it out by Friday if not sooner.

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

A Simple Servlet for Running JUnit in Glassfish

Posted by damuchinni on February 15, 2009

When teaching unit testing in the context of a simple EJB3.1 application, I was looking for an easy way of testing managed beans and session beans inside Glassfish. Of course, one can test out-of-container or use an embedded container (but I didn’t quite figure out how to do that with Glassfish v3—I’d appreciate hints), or a mock container (but that seemed to require a bit of setup).

I hit upon a scheme that I had not seen elsewhere: put the unit tests in the container and trigger them with a servlet that reports the outcomes. Advantages:

  1. There is very little setup to learn
  2. It is easy to run the tests from a browser
  3. The tests run in the exact same environment as your app
  4. No need to wait for container startup with every test. (This could also be a disadvantage because the database isn’t in a pristine state at the beginning of each test.)

Here is how to do it.

Add the JUnit 4 JAR to WEB-INF/lib.

Add the following servlet to your WAR file:

package myapp.servlets;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.junit.internal.JUnitSystem;
import org.junit.runner.JUnitCore;

public class TestServlet extends HttpServlet {
   protected void doGet(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
       String className = request.getParameter("class");
       OutputStream out = response.getOutputStream();
       final PrintStream pout = new PrintStream(out);
       new JUnitCore().runMain(new JUnitSystem() {
         public PrintStream out() { return pout; }
         public void exit(int arg0) {}
       }, className);

   protected void doPost(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
       doGet(request, response);

Add the following entries to web.xml:


Write your JUnit test case in the usual way. For example, here is a test for a session bean:

package myapp.session;

import static org.junit.Assert.assertEquals;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.junit.Before;
import org.junit.Test;

import myapp.entity.Person;

public class UserSBTest {
   private UserSB userSB;

   @Before public void init() throws NamingException {
      InitialContext context = new InitialContext();
      userSB = (UserSB) context.lookup("java:global/MyApp/UserSB");

   @Test public void testAddUser() {
      Person p = new Person();
      Person q = userSB.find("fred");
      assertEquals(p.getFirstName(), q.getFirstName());


Proverbial exercise to the reader: Add a green bar when the test cases pass.


Unfortunately, you can’t just have the container inject the session bean.

   @EJB private UserSB userSB; // Doesn't work when JUnit loads the class

When JUnit loads the class, it doesn’t deal with EJB annotations.

Then point your browser to http://localhost:8080/MyApp/test?class=myapp.session.UserSBTest

Posted in IDEs | Tagged: | Leave a Comment »

Bespin, IDE as a Service

Posted by damuchinni on February 15, 2009

Bespin adalah Cloud-Based IDE dari Mozilla Labs. Dibuat menggunakan elemen HTML 5 yaitu Canvas, sehingga browser yang digunakan harus brower yg mendukug HTML 5. Saya mencoba Bespin pada Firefox 3.0.6 pada Ubuntu 8.04.1 64-bit dan berjalan dengan cukup mulus. Tampilannya cukup bagus, dengan warna dasar gelap yang mengingatkan saya dengan produk-produk keluaran Adobe.
Bagus sekali, karena semakin banyak IDE yang berjalan di web browser. Ini menandakan bahwa IDE akan melangkah ke level yang lebih tinggi lagi.
Sepertinya HTML 5 (dan XHTML 2) bakal berperan besar dalam aplikasi web generasi mendatang. Kombinasi antara HTML + CSS + Javascript terbukti cukup ampuh untuk membuat user interface yang interaktif. Dan yang lebih penting, mereka ini adalah hypermedia. Kalo mau scale, kita butuh hypermedia untuk sistem berskala world wide web.

Bespin menjadi salah satu contoh aplikasi web dengan UI masa depan karena dia menggunakan Canvas yang merupakan elemen dari HTML 5.

Posted in IDEs | Tagged: | Leave a Comment »

JUnit 3 & JUnit 4: Oil & water

Posted by damuchinni on February 15, 2009

Version 4 of the popular JUnit test framework has been available for use for quite some time (In fact, it is up to version 4.5). However, many projects have a wealth of JUnit 3-style tests and developers may choose to continue using it. If, on the other hand, you decide to dip your toes in JUnit 4 waters, make it a complete immersion. Don’t try to mix and match.

As you may be aware, couple of the touted “benefits” of JUnit 4 are the obviation of extending the TestCase class and the identification of test and lifecycle methods (setUp and tearDown) using Java 5 annotations. For example, the following is a valid JUnit 4-style test case (minus the necessary imports):

public class BusinessLogicTests {
public void do_this_before_every_test() {
// set up logic goes here

public void clean_up_after_a_test() {
// teardown logic goes here

public void addition() {
assertEquals("Invalid addition", 2, 1+1);

Observe how

  • The class does not extend TestCase
  • The “setup” and “tearDown” methods are identified by annotations
  • The test method does not require a “test” prefix and is also annotated

I’ll let you be the judge of whether this is an improvement on JUnit 3. What I want to alert you to are the perils of subconciously mixing JUnit-3 and JUnit-4 style programming. Consider the following test case:

public class BusinessLogicTests extends TestCase {
public void do_this_before_every_test() {
// set up logic goes here

public void clean_up_after_a_test() {
// teardown logic goes here

public void testAddition() {
assertEquals("Invalid addition", 2, 1+1);

public void subtraction() {
assertEquals("Invalid subtraction", 1, 1-1);

This will result in a green-bar even though there is an error in the test of subtraction. Can you guess why?

It was that pesky little extends TestCase that I added from force of habit. The flips the switch to JUnit-3, which knows nothing about annotations, ignores my setup and teardown methods and looks for methods prefixed by test. It completely ignores the method named subtraction!

And of course, conversely, the following is just a plain old Java class that won’t be acknowledged by either JUnit-3 or JUnit-4.

public class BusinessLogicTests {
public void testAddition() {
assertEquals("Invalid addition", 2, 1+1);

Final word of advice, if you are using Struts Test Case, you have no choice but to write JUnit-3 style tests since the parent class of the framework (MockStrutsTestCase) extends Junit-3’s TestCase


Posted in IDEs | Tagged: | Leave a Comment »

Two Things You Never Knew You Could Do With The NetBeans Platform

Posted by damuchinni on February 15, 2009

I successfully investigated two areas of the NetBeans Platform that I knew should be doable but had never got round to proving:

  • NetBeans Platform as a modular framework for scripting languages. The approach is described in detail here, but could be adapted to any other scripting language. That would mean, for example, that Python developers could have a modular framework (including a shared filesystem, as well as all the many other goodies that the NetBeans Platform provides) in the same way that Java developers have the NetBeans Platform already.
  • NetBeans Platform as a tool for extending GlassFish. As described here, it’s fairly trivial to set up NetBeans IDE so that OSGi bundles are created instead of NetBeans modules. Then you could extend anything that’s built atop OSGi, such as GlassFish, for example.

Pretty cool to see these two thought experiments actually working in real life. Both of them, especially the OSGi solution, should definitely be incorporated into the NetBeans Platform Certified Training.

Posted in IDEs | Tagged: | Leave a Comment »