Tips and general rambling about Oracle JDeveloper, SCM, user interfaces, and other miscellaneous stuff.

Top Ten Toys for Java Coders in JDeveloper 10g


Oracle JDeveloper 10g (9.0.5) preview is now available, and includes plenty of new features will hopefully be appreciated by both RAD developers and code monkeys. I use JDeveloper as my main development environment and code editor when working on the product. This article lists ten of my favorite new features for the hardened Java hacker.

1. Semantic Underlining

Since 9.0.4, JDeveloper has provided syntactic underlining. If your Java code contained a syntax error such as a missing semicolon, a red underline indicated the offending code. In 10g, semantic errors are also underlined. These are errors in the logic of your code that would prevent it from compiling, such as method calls that throw unhandled exceptions, or references to classes that haven't been imported. Semantic errors are indicated by a blue underline (you can change this, of course, or turn this feature off completely if the underlines distract you from the important business of actually hacking code).

Screenshot of JDeveloper's code editor showing semantic underlining

2. Import Assistance

I like to keep Java code compiling as much as possible, so when I use a class from a new package namespace, I want to add an import for it immediately. The downside of this is that it involves a lot of vertical jumping about in the code editor. In JDeveloper 9.0.4, I was using the import completion feature to work around this. In 9.0.4, if you enter a fully qualified package name, e.g. "javax.swing." then pick the class name from the resulting insight popup list, an import is automatically added for the class.

The code editor in 10g goes one step further and tries to guess the import you need when it encounters an unrecognized class name. You can choose to ignore its suggestion, or press a hotkey (Alt+Enter by default) to automatically insert the suggested import statement.

Screenshot of the JDeveloper 10g code editor, showing the import assistance popup for an unrecognized class name.

3. Structure Window Sorting and Filtering

The structure window shows a list of classes, fields and methods defined by a java file open in the code editor. Sometimes, the sheer size of some of the classes I work with on a daily basis made the structure window less useful than it probably should have been. Probably time to do some refactoring, but in the meantime, JDeveloper 10g makes my life easier by letting me filter, sort and generally muck about with the items displayed in the structure window.

Screenshot of the JDeveloper 10g structure window, showing the new toolbar with sorting and filtering controls.

The toolbar buttons in the structure window provide the following filtering features:

Show Methods
Show Fields
Show Static Members
Show Public Members Only

4. Code Menu

A lot of functionality in the code editor was previously only available using shortcut keys. You could discover these features by going to Tools->Preferences and navigating to the Accelerators page. 10g makes it much easier to find coding features by adding a new Code menu when the editor is active. It's also handy as a reminder of several of the accelerators.

Screenshot of the new Code menu in JDeveloper 9.0.5

Update: In JDeveloper 10g production, the Code menu is now known as the Source menu.

5. Improved Javadoc Support

Support in general for Javadoc is much better in 10g. One feature I like a lot is the automatic Javadoc insertion. If you type /** and press enter above any public method that doesn't already have Javadoc, a template Javadoc comment is automatically inserted complete with @param, @return, and @throws tags. You can also invoke this functionality from Code->Add Javadoc Comments.

Screenshot of the JDeveloper 10g code editor showing an automatically inserted code template

When pressing F1 over a java identifier, JDeveloper has always displayed the relevant Javadoc page. However, the help window used to display the Javadoc was a separate top level window from JDeveloper, which made it hard to position the windows to look at your code and read the documentation at the same time. The new help system in JDeveloper 10g already makes this a more pleasant experience by providing an integrated help topic window you can position side by side with the code editor:

Screenshot of JDeveloper 10g, showing the code editor side-by-side with the help window.

Better still, when you press Ctrl-D (or use the Code->Quick Javadoc menu) inside a method, field or class name, a popup appears containing appropriately scoped javadoc:

Screenshot of the quick javadoc popup in JDeveloper 10g

6. Field Insight for Java Classes

In dialogs where you need to type a class name (e.g. Search->Go to Java Class...), a new feature in JDeveloper 9.0.5 provides an insight list of available classes as you type. This is a great alternative to browsing the class hierarchy using a separate browse dialog.

Screenshot of field insight in JDeveloper 10g

7. Audit and Metrics

JDeveloper 10g has new tools for auditing and calculating metrics on your code. Of the two, I find audit most useful. It's great for helping to keep code tidy, following coding standards, with complete and correct javadoc tags etc. There's a large amount of audit functionality, including the ability to create profiles consisting of specific audit rules, the ability to define new rules via an extension API, utilities for automatically fixing audit violations, and command line support for running audit outside JDeveloper.

Screenshot of the audit log in JDeveloper 10g

8. Surround With

Using the Code->Surround With... menu, you can easily insert several coding constructs.

Screenshot of the surround with dialog from JDeveloper 10g

It's particularly handy for inserting try/catch blocks. It even automatically inserts any required import statements for exceptions caught in the catch clause.

Screenshot of the JDeveloper code editor showing an automatically inserted try/catch block.

9. Generate Accessors

Code->Generate Accessors... provides a quick way to create get...() and set...() methods based on existing fields of a class.

Screenshot of JDeveloper 10g's generate accessors dialog.

 

10. Log Window Color Coding & Hyperlinks

The log window in 10g now uses two different colors to distinguish stdout and stderr output. If an exception stack trace is dumped to stderr, hyperlinks are displayed in the log window making it easy to jump to the offending code.

Screenshot of the log window in JDeveloper 10g showing output colors and exception hyperlinks.

weblog   |   articles
© Copyright 2003 Brian Duff. Last Updated 14/10/2003; 12:24:34. Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries.