Geertjan is a DZone Zone Leader and has posted 459 posts at DZone. You can read more from them at their website. View Full User Profile

Using IntelliJ IDEA for NetBeans Platform Development

03.04.2009
| 17203 views |
  • submit to reddit

On jetbrains.com there's a rather impressive article entitled Using IntelliJ IDEA for Eclipse RCP development. Let's take a look at what the NetBeans Platform equivalent would look like.

We'll start with one of the standard NetBeans Platform sample applications distributed with NetBeans IDE, the Paint Application.

The application consists of an application module that provides a canvas for painting, with some 3rd party libraries wrapped into supporting modules. In other words, a very realistic example representing a real life scenario.

We're going to (1) open that application into IntelliJ and then (2) deploy it from IntelliJ, with this result:

In the picture above, take a look at the application structure, as well as the running application itself. That's what we're going to be creating in the steps that follow. I.e., we will make full use of the NetBeans Platform, while using IntelliJ to do so.

  1. Create the Application. Open NetBeans IDE and create the Paint Application, which you can find in the New Project dialog.

  2. Import the Application into IntelliJ. Open IntelliJ and choose File | New Project | Create project from scratch. Click Next. In "Project files location", set the "PaintApp" root folder. Type "PaintApp" in "Name". Click Next and keep clicking Next until you can click Finish. I.e., don't change any of the defaults. Now the application is open in IntelliJ.

  3. Add the NetBeans Platform to the Classpath. Right-click the main "PaintApp" node and choose "Module Settings". In Dependencies, create a new project library that contains all the JARs that you can find in the NetBeans installation directory's 'platform9' folder. Make sure to look in the 'core', 'lib', and 'modules' folders. You should end up with a very long list of JARs. Also make sure to add 'ColorChooser.jar' (which is in 'release/modules/ext' within the Color Chooser module) in the same way.

  4. Create a Runtime Configuration. In the toolbar, click 'Edit Configurations'. Create a new configuration, named 'NetBeans' (for example, but name it whatever you like). Set 'org.netbeans.Main' as the 'Main class' (you should be able to browse to it in 'boot.jar'). in 'VM parameters', pass in some VM options for setting the user directory of the application (which would normally be set via etc/netbeans.conf when NetBeans IDE starts up, which it won't do in our case), as well as the home directory. The user directory can be anywhere, while the home directory must be the cluster that is created by the build process:
    -Dnetbeans.user="/home/geertjan/idea/paint-userdir" -Dnetbeans.home="/home/geertjan/idea/PaintApp/build/cluster"

    The above implies that the cluster exists, which implies that a build has been performed. That's why I do the build from NetBeans IDE. That creates the cluster and then the above VM option works. Instead of VM options, you can also use other approaches to ensure that the application knows where the installation and the user directory are, as discussed here in the comments.

  5. Turn Folders into Source Folders. Go back to the Module Settings and then use the Sources tab to set 'branding' and 'build' as sources. (After you do this, the folders will turn blue.) The 'Paint/src' should already be marked as sources.

Now run the application, using the runtime configuration you defined earlier and you should see your application deployed. Now do the same to the FeedReader Application, which is also distributed with NetBeans IDE, and you should end up with a successful result, following the principles outline above.

Finally, what's the benefit of all this? Well, for far too long IntelliJ users have been excluded from the wonderfulness of the NetBeans Platform. Now, following these instructions, you can at least get started. You'd use NetBeans IDE for generating the project structure and API stubs, as well as for the Matisse GUI Builder's support for the TopComponent class (and other UI classes), after which you'd do your coding in the IntelliJ Java editor. (And the IntelliJ XML editor has better support for the NetBeans Platform layer.xml file than NetBeans IDE does.) Or you'd have different developers working in different IDEs, sharing the same codebase in the way outlined above.

An interesting discovery is that a NetBeans Platform application deploys much more quickly from IntelliJ than it does from NetBeans IDE.

 

AttachmentSize
fig-1-idea.png83.13 KB
Published at DZone with permission of its author, Geertjan Wielenga.

Comments

Dan Lewis replied on Thu, 2009/03/05 - 9:57am

Do I understand correctly that this still requires the use of the NetBeans IDE to do the actual build step?

Geertjan Wielenga replied on Thu, 2009/03/05 - 10:59am

Not necessarily. Firstly, "no", because the approach taken in step 4 could probably be done in a better way. Secondly, "no", because you could do the build step anywhere (e.g., outside NetBeans IDE, from the command line or inside IntelliJ, using the build script).

Willis Morse replied on Thu, 2009/03/19 - 9:59am

Thanks, this is great info. While I would love to adopt the Netbeans Platform and use many of the Platform RAD tools that are available in Netbeans, there's no way I'm giving up the editing power of Idea. How often will you have to go back to the Netbeans IDE? Presumably you will need to run the Netbeans IDE in order to use any of the Netbeans GUI wizards and editors, right? Are there any other big tasks in a Platform-based app that must be done in the Netbeans IDE? What about changes to the project (ie - adding a library, creating a new module, etc). If you change the project in the Netbeans IDE, can you get those changes into the Idea project seamlessly, or are you forced to throw out the Idea project and create a new one by re-importing?

Piero Sartini replied on Sun, 2009/04/19 - 3:35am

@willismorse: There is also the possibility to use maven to assemble your platform application. This approach should be IDE-agnostic. You loose the wizards and some NetBeans-magic, but it is possible to develop without these things. Even when developing with NetBeans you will come to the point where you don't use the wizards.

NBM Maven Plugin: http://mojo.codehaus.org/nbm-maven-plugin/

Korben Dallas replied on Fri, 2010/08/20 - 2:56pm

Hi,

I tried it and it works well for me. But there is one thing which I miss. As soon as the Netbeans container has started, no further logging is done to the console window of my idea IDE. When I run the same project from the Netbeans IDE, loggin is done to the output window of Netbeans IDE.

So the question is: how can I configure my Idea or my project, so that the error output and the standard output will be shown in the output window? If this is not possible, does anyone know in which file the logging is done?

Matt Coleman replied on Fri, 2012/11/16 - 12:45am

IntelliJ IDEA is an awesome piece of program that NB is using.I feel Korben is right on some pointssell sheet designer 

Bryan Low replied on Sun, 2013/02/24 - 4:48am

A wonderful and unique lifestyle awaits you. Please see Bartley Ridge project details and units available for more information.

http://bartleyridge.org

John Tan replied on Sat, 2013/08/03 - 6:36am

 The executive condominium at Waterwoods is just a 3 mins walk to Coral Edge LRT and Punggol Plaza. It is just 3 LRT stops to Punggol MRT and new Mega Shopping Mall (Waterway Point). WaterWoods is easily accessible to Tampines and Changi Airport via TPE and also only a 20 minutes drive to Town via KPE and the upcoming Marina Coastal Expressway.
http://www.thewaterwoodsec.com

John Tan replied on Sat, 2013/08/03 - 6:36am

 Just 2 Bus stops away is the White Sand Mall, The Pasir Ris MRT station and the Pasir Ris Bus interchange which is very near to Sea Horizon.  Basically everything you need can be found in Pasir Ris. Travelling either by bus or MRT train and also expressway (TPE , PIE and ECP) making Pasir Ris a convenient place to stay and play.
http://theseahorizonec.com

John Tan replied on Sat, 2013/08/03 - 6:36am

 With Sembawang MRT Station a couple minutes walk away, residents can enjoy the luxury of time assessing other parts of Singapore and the conveniences nearby with ease.
http://sky-parkresidences.com/

Commonwealth Towers replied on Mon, 2014/04/07 - 9:16pm

“Together, these two government assistance schemes, at $167 million, translated to about 36 percent of town councils’ operating expenses. This is quite substantial and helps reduce the financial burden on residents,” noted Mr Khaw. landed residential

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.