[UPDATE on 12/20/2012]. To the best of my knowledge, IntelliWO no longer works in IntelliJ (version 10) because the plugin API changed somewhere around version 7 or 8, and we've never updated it. We've posted the source code with the IntelliJ project at http://static.360works.com/intelliwo.zip, so if anybody would like to download it and update it for the new IntelliJ plugin API, feel free! IntelliWO is licensed under the LGPL terms, which means that if you improve it and redistribute it you must make your changes publicly available. We'd appreciate it if you could also send us a copy of your changes if you make any improvements.

If you're reading this, then you probably already know why you'd like to use the IntelliJ IDEA development environment, so I'll skip talking about why it's great. Suffice to say that for our development, we are tremendously more productive than we were with Project Builder. If you have not had a chance to try it yet, download a free evaluation from http://www.jetbrains.com. Unlike Eclipse or XCode, it is not free, but if developing Java or WebObjects applications is something you spend much time with, it is absolutely worth the price.

This article talks about how you can get IDEA to work with WebObjects. You can also download our open source IntelliJ plugin for conveniently integrating WebObjects and IntelliJ.

You should start by downloading these tutorial files, which includes our standard Ant build script, some file templates, and the example IDEA project file for this tutorial.

  • Compatibility: All of our development is done on OS X 10.2 and 10.3, with a mixture of WebObjects 5.2.1 and 5.2.2 (have not tested yet in 5.2.3). We use Java 1.4.1 in 10.2, and 1.4.2 in 10.3. The basic concepts in this article should be applicable to any platform, but some of the optional goodies in our IntelliWO plugin are specific to Mac OS X. As long as the directory structure is set up as outlined in this article, projects can be shared with other developers working with Project Builder, XCode, and Eclipse, so this is not a "one way" transition.

  • The basics - creating, compiling, and running a new WebObjects application.

    • This first step will assume that you are running IDEA for the first time - you may wish to skip this section if you are already using IDEA. We'll start by creating a new project.

      • JDK setup: When you first launch IDEA, it will ask you to specify a project location. After that, it will ask you to configure your project JDK. Create a new JDK and point it to your Java home directory (/Library/Java/Home by default in OS X). At this point, you do *not* need to include any WebObjects-specific settings; we will do that in a later step. Also note that if you have the source code for the basic Java SDK, you do not need to specify the location of the JavaDoc files for this - IDEA will generate them automatically from the javadoc comments in the source code. Click to see an example JDK setup.

      • Module, source directory, and compiler output path: Create a single Java module after selecting the JDK (you can add additional modules later for shared code projects, similar to frameworks but better). For the source path, create a 'Resources' subfolder at the top level of your project and put the 'src' directory inside that (reasons for this will be explained below in 'Directory structure'). For the compiler output path, create a 'Java' directory inside the 'Resources' folder and select that. After these settings are done, you should arrive at the main project window. P.S. - don't ignore the Tip of the Day window - there are some really cool tricks that you will learn from that.

    • Configuring WebObjects libraries: Configure a global library (File->Settings->JDK & Global Libraries) for WebObjects. See the attached screenshot for an example of my setup. After you've configured this, go to File->Settings->Paths->Libraries and check the box by the WebObjects library to enable it. Example WebObjects global library - includes all of the jar files from the standard WebObjects frameworks.

    • File Templates: In the downloaded files for this tutorial, I've included a 'fileTemplates' folder with default files for WOApplication, WOSession, WODirectAction, and WOComponent. If you drag these into your home directory->Library->Preferences->IntelliJ IDEA->fileTemplates folder, they will appear in the new files list.

    • Creating WOComponents: Create a new WOComponent subclass in whatever package you'd like to use. After you create the WOComponent java file, run the 'refresh PB' ant script (see 'Ant Integration' below). Then go into WebObjects Builder (WOB), create a new component, and save it into the Resources folder. Click 'no' when it asks you if you want to insert it into the project. At this point, you should be able to work in WOB as normal, including creating variables in your source file from within WOB. You can skip the 'refresh PB' ant script, but if you do, you will not be able to see or edit your variables within WOB. Also note that if you are running WebObjects 5.2.2 or later, you will need to modify your PrivateFrameworks folder to see your source variables within WOB. See http://www.objectstyle.org/woproject/wolips.html for details.

    • Directory structure

      • You can store your project files in pretty much any location you'd like, as long as you customize your Ant build script to point to the proper locations. However, we've devised a standard directory structure that accomplishes two goals: One is that by mimicking the structure of a WebObjects application bundle, you can run your WebObjects applications without having to do a build. This is a great time-saver for development. The second advantage is that it preserves the ability to coexist with Project Builder / XCode, if you keep your Project Builder project file up to date. The key concepts are that you put just about everything (including the source and output directories) inside a Resources folder. You should also add EOModel files, .wo folders, d2w rule files, and static web server graphics and resources in this folder. Here is a screenshot of the folder structure for our example

    • Running your application: With the 'buildless' directory structure that we've outlined, you can simply compile your java source files and run the Application class. No builds, no shell scripts, just plain java. See the screenshot for a setup example. You can also use the debugger option, which uses the same setup and allows you to use the Hotswap feature for modifying the code in your live application, in addition to standard debugging features. To hotswap your code, just change your source files and do Build->Make Project while your application is running. To build the final application for deployment, see 'Ant Integration' below. Here is an example run configuration setup.

  • Ant Integration: If you're not familiar with Ant, the documentation is at http://ant.apache.org/manual/index.html. I've included an example build script that should work for most application that use the directory structure outlined here.

    • Show the ant build window in IDEA. Click the + button to add a build file. Select the generic_build.xml file.

    • Highlight the 'Generic project' line and click the properties button to configure the ant build. For applications, you will need to configure three properties: projectName, basedir, and principalClass. See the screenshot for an example. Click here to see an example setup.

    • Click the Additional Classpath tab and add the two WOProject jars (download from http://www.objectstyle.org/woproject/). This screenshot shows an example setup.

    • You should now be able to run the ant tasks by double-clicking them. To use the build_framework task, you'll need to define an additional property, 'frameworkDestDir', which should usually be set to '/Library/Frameworks'.

    • In WebObjects 5.2.3, before you can successfully run the application, you may need to first build the application with Ant and copy the Info.plist file from the built application into the Resources directory. Please note that we have done very little testing with WebObjects 5.2.3.

    • The 'refresh_pb' script is used anytime you add a new WOComponent subclass, so that WebObjects Builder will be able to display the source variables.

I hope that this article has been helpful. We'd love to know if this article was useful to you, as well as an feedback or suggestion you have. If you have time, just let us know what you think!