Welcome!

Java Authors: Maureen O'Gara, Liz McMillan, Walter H. Pinson, III, Yakov Werde, Tony Bishop

Related Topics: Java, PHP, Ruby

Java: Article

NetBeans: It's Not Just for Java Anymore

Using dynamic languages

Therefore, even though you can do things like switch superclasses on-the-fly and even though this sort of thing is occasionally useful, most real code is not going to be written that way in a dynamic language. In most dynamic language code there is plenty of information available to a code editor for Ruby or JavaScript to analyze – it’s just a harder, messier problem than with a strongly typed language like Java. NetBeans 6.1 proves it can be done and done well.

Ruby Support
Ruby support in NetBeans 6.0 includes all of the features Java developers have come to expect from an IDE, such as:

  • Code completion
  • Warnings and quick fixes
  • Integrated pop-up documentation
  • Support for building projects with Rake

NetBeans 6.0 bundles the JRuby runtime, an interpreter for the Ruby language written in Java (native Ruby can also be used). It also includes the popular Rails Web application framework. With a single download you get a complete, ready-to-run Ruby development environment – with no additional downloads or installations needed. Since JRuby is a Java implementation of a Ruby runtime, there are additional benefits. Java and Ruby code can call each other, making mixed-language projects viable in new and interesting ways. The Ruby language is concise and excellent for text processing; Java’s type-safety and the huge body of existing libraries and frameworks means these languages complement each other nicely. The marriage of Java and Ruby gives developers more freedom to choose the right tool for the job.

JavaScript Support in NetBeans 6.1
NetBeans 6.0 does a remarkable job of providing editor features for Ruby that Java developers have been enjoying for years. NetBeans 6.1 does the same things for JavaScript programming. In the case of JavaScript, it includes a number of popular libraries including Dojo, YUI, and JQuery – including integrated pop-up documentation for them (see Figure 1). In addition, type assertions (documentation hints about the types of parameters). Tools for in-browser debugging will be available in beta shortly after NetBeans 6.1 is released. The NetBeans IDE comes with its existing HTML, CSS, and XML editors, which provide code completion, pop-up documentation, etc.

Code completion for both Ruby and JavaScript in NetBeans 6.1 is more than just showing class members and available keywords; it’s actually sensitive to where the editor caret is. For example, as shown in Figure 2, if the caret is inside a regular expression, it will show regular expression code completion rather than the normal JavaScript or Ruby code completion.

Similarly, code completion works inside string literals – so if the editor determines that you are referring to an HTML document, it can provide appropriate completions (see Figure 3).

A lot of attention has been paid to editor hints – warnings and quick fixes – in the JavaScript editor in NetBeans 6.1. For example, the following is legitimate JavaScript code, but will break in Internet Explorer:

point = {
x : 1,
y : 1,   //This is a trailing comma and will break in IE
}

The IDE will show a warning similar to Figure 4 and offer to fix the error automatically. You can customize the list of browsers you’re targeting, and this will adjust the list of warnings you get. This sort of functionality has been available in Java editors for some time – but bringing it to the JavaScript language is something new.

PHP Support
PHP is one of the most popular Web development frameworks on the planet. Work is going on to build PHP tooling into NetBeans, including debugging, and the same advanced editor features NetBeans 6.1 offers for the Java, JavaScript, and Ruby languages. It will be available as a beta when NetBeans 6.1 is released. It can be downloaded now in daily builds as a standalone PHP development tool.

Getting Started with NetBeans
There are a number of NetBeans configurations available for different needs. Go to http://www.netbeans.org and click the download link on the front page to download the IDE. You may need to get a milestone or development build for the new PHP support, which will be in beta when NetBeans 6.1 is released. Figure 5 shows the configurations available.

If you get one of the smaller bundles, you can always use Tools > Plugins to download and install additional tools and language editors later. The NetBeans Plugin Portal, http://plugins.netbeans.org/ also offers additional community-developed plug-ins for a wide range of technologies. Even if you are happily using another IDE, the NetBeans 6.1 release is worth a look.

More Stories By Tim Boudreau

Tim Boudreau is a senior staff engineer at Sun Microsystems. He has been working on the NetBeans project for nine years and is co-author of "NetBeans: The Definitive Guide" from O'Reilly and Associates, and "Rich Client Programming" from Addison Wesley.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Christopher Judd 06/27/08 11:03:36 AM EDT

Nice article. But I am surprised you did not mention the upcoming Groovy support when you mentioned the upcoming PHP support.