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

Top 10 New Java Features in NetBeans IDE 6.5 (Part 1)

12.27.2008
| 25557 views |
  • submit to reddit

Though the latest release of NetBeans IDE focuses very heavily on dynamic languages, and PHP in particular, there are many new and enhanced features that should appeal very specifically to Java programmers. The complete feature list for the entire release of NetBeans IDE 6.5 is really long and colorful, but let's focus specifically on 10 of the Java-related highlights. Let's begin by putting on a Java programmer's hat and ask the question: "Which, of the many cool new things, would be particularly appealing to a Java programmer? And why should a Java programmer now consider NetBeans IDE 6.5 above its competitors?"

That immediately cuts out a lot of the dynamic language stuff (i.e., throw the cool Ruby, Python, and PHP things out the window), as well as the things that relate to using the IDE in some special way. Just bare bones Java stuff is then left. And the highlights of these are, in my opinion, the following, in order of significance:

  1. Performance Improvements. If there is one area that every Java programmer (indeed, any programmer at all) is interested in, it is performance of their IDE. Discussions on this theme rage all over the web—the IDE that, despite its growing feature set, continues to be (and enhances the extent to which it is) performant is the one where most programmers will flock to. More so than any other (assuming the feature set is competitive), this is the distinguishing feature between IDEs, if the difference between them on this point is significant enough. Even more so than before, NetBeans IDE 6.5 focuses on this aspect. Since several releases, a performance team exists within the NetBeans engineering group (led by Jaroslav Tulach, one of the founders of the project who, more than anyone else, knows where to tweak and tune small things to big effect), focused very specifically on these aspects: ensuring that the startup time of modules in the system is acceptable, enhancing the hooks by which objects are created, attempting to ensure that this is done as lazily as possible, etc.

    Performance covers many areas, from start up time, to editor responsiveness (i.e., if you need to wait for the code completion box to appear, you have a performance problem), to the speed at which dialogs such as the Options window appear. Also, as applications increase in size, to a point where they become extremely large with many thousands of files, there is an inevitable performance impact: the trick is to keep this impact as limited as possible. (A related problem is reproducing the related issue reports: if your performance problem occurs when you have a freshly opened project consisting of hundreds of thousands of files, there's a chance that your problem will be hard to reproduce, and a related chance that your application isn't optimally designed to begin with).

    One way in which performance hits are kept to a minimum is that, for the first time, starting from NetBeans IDE 6.5, a node within a tree hierarchy is created only when it is needed (i.e., as the user scrolls down the Projects window, for example) and not before that point. More generally, modularity relates to this too, in that you should install the IDE distribution that you need: if you are "only" a Java desktop developer, for example, you should not get the NetBeans distribution that includes web features and mobile development features. These additional features are provided by additional modules, which would need to be started up superfluously, extending your startup time while giving you no features that are of use to you.

    In short, it is hard to imagine how seriously issues of performance are taken by the NetBeans team. Is that new in 6.5? No, but several of the API enhancements that have been done for 6.5 have been done specifically for this very particular purpose, i.e., to ensure that the IDE continues to improve its performance while at the same time acquiring new features. These two requirements are, in the absence of this specific focus, mutually exclusive. In even shorter, a significant performance improvement should be noticed in 6.5, from start up time, to editor responsiveness, to everything you do in the IDE, though a key element is choosing the right distribution for your needs.

  2. Compile & Deploy on Save. One of the key features that has distinguished NetBeans by its absence, 6.5 now includes. Better than describing it in words is to show it in action. Watch the video below for details.


  3. Groovy. More than any other scripting language, Groovy lends itself to handling the heavy lifting of traditional cumbersome Java tasks, without requiring you to make a huge mental shift to start using it. The ease with which this is possible is quite amazing:

    (In other words, just code your Groovy class in Groovy and then, in your Java class, simply pretend the Groovy class is a Java class, which is what it will become anyway when you compile it, and call its methods as you would do with a Java class.) Yes, the introduction of Groovy is a feature enhancement for Java programmers. Here's one of many simple examples to that effect:

    Indeed, don't take my word for it, but see, for example, some of the comments at the end of this NetBeans IDE 6.5 release announcement and absorb the enthusiasm with which this feature in 6.5 is being welcomed.

  4. Java Editor Enhancements. An area where NetBeans IDE has consistently improved, while continuing to lag over its peers, is the Java editor, in terms of its performance (see above) and, in particular, its range of refactorings. In fact, any presentation done by any NetBeans presenter (ever, I dare say) has been followed by the question/statement: "Yes, but IDE XYZ has more, better, and faster refactorings." In this sense, whether NetBeans IDE 6.5 equals another IDE in this regard is not as significant as whether it enhances significantly enough for the enhancements to be noticeable, since it always comes out with code-generation tools that are superior to its peers. If editor progress is consistent across releases, and there are significant other features (such as code-generating tools) being introduced at the same time, it is clear that a concerted attempt is being made to catch up and, even, improve on competitors' offerings.

    Here are a few indications that this is certainly the case in 6.5:

    • Code Completion. The jewel of any code editor is, I believe, together with the "hints/tips" feature (so wonderfully represented in IntelliJ), the code completion feature. Any enhancement in this area, after performance, is inevitably very fine grained, which is exactly the level at which code completion is most useful. One enhancement in this area to have made its way into NetBeans IDE 6.5, is CamelCase code completion:

      You can simply write the first letters of a word to get smart code completion. As shown above, "iL" expands to invokeLater. In addition, for the first time, code completion has been introduced into the SQL Editor, which is no trivial improvement for Java developers who need to work with databases (and what kind of developer doesn't?):

      (In the SQL Editor, there are a number of other significant improvements: SQL history, editable & sortable results, multiple tabs for different results, with several more in the planning for the next release.)

    • Creating Getter/Setter from Existing Variable. When you want to refactor a variable such that it acquires a getter/setter combination, these are all the options available in 6.5...

      ...compared to 6.1:

    • Call Hierarchy Analyzer. Want to know how a method relates to another method? For example, which code in your application is calling the current method? And which code is being called by it? Nothing simpler in 6.5 than right-clicking on the line and then choosing "Call Hierarchy". A new window will open, with several buttons for refreshing the view, either with callers or callees, and setting filtering options: 

    • Formatting Refactoring. Another area where NetBeans IDE has had room for improvement is that of formatting. Formatting options have always been settable IDE-wide, never project-wide, unlike (for the first time) in 6.5:

      I.e., the entire tab that you see above wasn't there before 6.5.

    • Javadoc Refactoring. For another example of editor improvements, let's look at this piece of code:
      public class HelloWorld {

      /**
      *
      * @param name
      */
      public String SayHello(String name) {
      return "Hello" + name;
      }

      }

      Now, I decide that the age needs to be passed in to the method, so I add a new parameter:

      public class HelloWorld {

      /**
      *
      * @param name
      */
      public String SayHello(String name, int age) {
      return "Hello " + name + ". You're " + age + " years old.";
      }

      }

      And so, in this situation, you can now (from 6.5 onwards) right-click on a node (e.g., on a Java package or class in the Projects window) and choose Tools | Analyze Javadoc. In the above code, the IDE would then show you the following window:

      As you can see, this feature lets you update your Javadoc very easily. Place checkmarks by the Javadoc fixes you'd like the IDE to implement for you, as you can see below:

      Then click "Fix Selected" and some simple Javadoc stubs are created for you:

    • Java Editor Related API Changes. Some of the (many) API changes that have taken place in the 6.5 timeframe are very relevant to the Java editor. For example, the small code generator popup that appears when you press Alt-Insert can now be extended. This means that you can add your own entries there which, as a result, will let you generate additional/custom code snippets into the Java (or any other) editor. Previously, the code generator popup was only available in the Java editor, while now it can be added to any editor at all, i.e., either one of the IDE's default editors (such as the HTML editor, as shown here, or the JavaFX editor, as shown here) or a custom editor created externally.

      Another example is that the Palette API has been enhanced so that, if a palette makes use of this enhancement, you are now able to drag snippets of code from the editor into the palette (as well as the other way round, of course). That's handy for storing your frequently used code snippets for later reuse. The API in question has been applied to the palette for HTML files only, in 6.5, but this will probably be extended to all the other palettes too (and you can very simply apply it to your own custom palettes that you might already have).

  5. Matisse GUI Builder Enhancements. The Matise GUI Builder is not everyone's best friend, but should definitely be more so now that 6.5 is out. Some pretty sophisticated changes have been made, partly to simplyify working with the GUI Builder's user interface and partly to improve the generated code:

    • Brand New Swing Component Editors. Working with JTree models has never been much fun but now, dare I say it, it's very close to being that, with this brand new JTree model editor:

       

      In other words, the above is not an enhancement, but a completely new editor, with a free form space, as you can see above, where you can simply type text and, based on the indentations, the JTree model is constructed by the editor.

      A similar thing has been done for the JComboBox and the JList. Here's the JList Editor, first in 6.1, and then the new free form 6.5 version:

    • Nimbus Previewer. When designing your layout in the Matisse GUI Builder, you can very easily preview your current state in the new Nimbus look & feel:

    • Many More GUI Builder Customizations. Compare these two screenshots, the first from 6.1 and the second from 6.5, to see how much has changed in terms of what can be configured globally:

      Here my favorite enhancement is "Generate Fully Qualified Names of Classes" which, when deselected, ensures that the import statements get added to the top of the class while the code statements themselves are as short and compact as possible. Also useful for refactoring, because when the class you are referencing moves to a different package, you need only update your import statements, which are all neatly at the top, rather than stuck within the blue blocks, which are considerably less easy to edit.


And that is the end of part 1. In part 2, we will look at 5 other features in NetBeans IDE 6.5 specifically targeted at Java developers, in particular at tools such as the Debugger and Profiler, tools that any user of NetBeans IDE should be able to get familiar with to great effect. Until then, have fun with NetBeans and make sure to pass on to the NetBeans team any comments good/bad/ugly that you might have.

 

 

AttachmentSize
fig-1.png46.31 KB
fig-2.png35.29 KB
fig-3.png56.96 KB
fig-4.png59.05 KB
fig-5.png59.77 KB
fig-6.png60.85 KB
fig-7.png13.2 KB
fig-8.png40.14 KB
fig-10.png34.08 KB
fig-9.png24.37 KB
fig-11.png12.76 KB
fig-12.png15.55 KB
fig-13.png38.95 KB
fig-14.png18.62 KB
fig-15.png43.54 KB
Published at DZone with permission of its author, Geertjan Wielenga.

Comments

Mark Thomas replied on Sun, 2008/12/28 - 2:40pm

To what extent does #3 also apply to JRuby? Can I create a JRuby class, and then from my Java class simply pretend that the JRuby class is a Java class? If not, how close can you get to that?

Alex(JAlexoid) ... replied on Sun, 2008/12/28 - 9:51pm

My current biggest problem with NetBeans is that their Java Editor is stagnating compared to Eclipse's. While all other features are much better done in NetBeans, for pure Java Coding, Eclipse wins on every point.

Oh and the bigest annoyance are the mnemonics. Sorry, I want thm to be available in a Crtl+Space popup and autocomplete should work on them.(But, unfortunately I can't contribute because of a job contract)

Oscar Vega Gisbert replied on Mon, 2008/12/29 - 5:05am

Code completion is useful for many people, but for me not.

I can deactivate code completion on Netbeans 6.1, but on 6.5 version Netbeans popups to code completion ramdomly. I deactivated it, but 6.5 still popups... So I returned to 6.1 version.

I understand that many people likes code completion, but for me it is trouble.

Geertjan Wielenga replied on Mon, 2008/12/29 - 6:19am

Oscar, I tried to disable code completion and came to the same result as you. (But why do you want to disable it?) I created an issue, please add your experiences to it:

http://www.netbeans.org/issues/show_bug.cgi?id=156127

Geertjan Wielenga replied on Mon, 2008/12/29 - 6:24am

Alex, one can argue about whether the Eclipse editor is better than the NetBeans editor. However, one cannot argue that the NetBeans editor is stagnating: in fact, every release shows enhancements, which is one of the arguments in this article. In what ways do you see it stagnating?

Geertjan Wielenga replied on Mon, 2008/12/29 - 6:25am

Mark, good question. But I don't know the answer. Maybe someone else reading this does. I've not investigated JRuby (or Ruby) at all thus far, not having found a reason to do so.

Alex(JAlexoid) ... replied on Mon, 2008/12/29 - 6:36am in response to: Geertjan Wielenga

It is definitelly improving, I do not argue on that point. I am saying that compared to Eclipse's Java editor pace of improvements.

And there is another quite irritating issue with NetBeans - you can only have jUnit tests in tests. I already filed an issue.

pugalendhi Ganesan replied on Mon, 2008/12/29 - 8:08am

I'm having some problem with debuging in 6.5.. every time the control stop at the first break point IDE opens Java.lang.Object source code file, i don't know why it happens.. some times even control is not stoping at break points, currently I'm using both 6.5 (for development) and 6.1(debugging)... Any one experence this same problem or i'm alone..

(Note : I'm developing Java ME app)

 

Oscar Vega Gisbert replied on Mon, 2008/12/29 - 9:56am in response to: Geertjan Wielenga

Geertjan, sometimes I write code very fast. When NetBeans popups seems to me as a stumble. I usually remember the method names and I like read javadocs.

Another option I usually deactivate is "Insert Closing Brackets Automatically", beause it force me pressing end key to write semicolon... (another stumble)

Actually, I have all options of "Editor / General" tab deactivated...

James Selvakumar replied on Mon, 2008/12/29 - 10:10am

Hi Geertjan,

Thanks for the wonderful article. The information about "Analyze Javadoc" and "Call Hierarchy" were eye opening for me.

Wade Chandler replied on Tue, 2008/12/30 - 8:52am in response to: Alex(JAlexoid) Panzin

I would say the NB editor is far from stagnated. It gets better and better. Too, I don't think Eclipse folks have been trying the NB editor as much as stuck on this idea that the NB editor is bad. Just because the NB editor != Eclipse editor doesn't mean it is bad, but instead it just means different. Use it and get to know where the actions are, and you may find as I recently did that NB is much more productive once you know how to use it. I just finished using Ganymede over the holiday, and I was far from impressed, and was looking at it as a person trying to find features and compare them digging through options etc. I found NB to work better these days. Too, I couldn't find any features in Eclipse that I didn't have in NB. Can you name some?

Alex(JAlexoid) ... replied on Tue, 2008/12/30 - 9:39am

[quote=Wade] It gets better and better. Too, I don't think Eclipse folks have been trying the NB editor as much as stuck on this idea that the NB editor is bad.[/quote]

I am far from the Eclipse person. I have been using Eclipse for 2 years, while I have been using NetBeans since it was Forte for Java. And I do believe it has been getting better and better.

new Rant().start();

My main problems are that NetBeans editor is either in your face when it's not needed or it's not there when you need it - particularly the Code Templates are just horrible and the popup either displays everything under the Sun or nothing at all.

Do you really remember all the Code Templates' abbreviations? If, no WHY, OH WHY are so little of them in the popup? And why can't I expand it after the code completion popup closes?
Sample #1: Try typing "so" then press Ctrl+Space, then Esc to close the popup(since it does not contain that abbreviation) and type in "ut" and press Tab(or whatever your expansion button is).
Sample #2(Intuitive popup failure): Create new class named Main, in the body of the class press Crtl+Space - Why would it not give me an option to create psvm? It's a standard entry point!

Oh and let us not forget about the consistency of those templates... Why 'public static void main' is 'psvm while 'public static final String' is 'Psfs' and 'private static final String' is 'psfs'?

That takes care of effective 'coding' in pure Java.

And don't let to start ranting on Eclipse's failures in it's editor, that would take A LONG time and a hudge post.

Ryan Developer replied on Tue, 2008/12/30 - 11:47am in response to: Alex(JAlexoid) Panzin

@Alex: First, thanks for taking the time to point out some shortcomings in the NetBeans editor.  There is a new NetBeans Voice Of Community group that is supposed to be scanning for posts like this to make a list of community raised issues, prioritize them, and to provide the list to Sun. Sun has agreed to address at least the 30% of VOC issues [in each release?]:

wiki.netbeans.org/VoiceOfCommunity

[quote=jalexoid]

And don't let to start ranting on Eclipse's failures in it's editor, that would take A LONG time and a hudge post.

[/quote]

I think there are a lot of people who would be very interested in such a post. If you have the time, please write a blog post or javalobby article about it.

Peter Karussell replied on Tue, 2008/12/30 - 2:48pm

Hi Geertjan,

another great enhancement: the "action, options and help"-quick-search on the top right. It is a good copy of the mac OS built-in functionality. But now for all operating systems :-)

Alex(JAlexoid) ... replied on Tue, 2008/12/30 - 3:31pm in response to:

Just to note: I already have created the issues: 152153, 152154, 152155, 152156 - if you're interested...

Wade Chandler replied on Tue, 2008/12/30 - 6:21pm in response to: Mark Thomas

Well, it is indirect. For instance, for Java 6 scripting, you need:

https://scripting.dev.java.net/servlets/ProjectDocumentList?folderID=8848&expandFolder=8848&folderID=0

 

Then you can use code such as:

package javaapplication5;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.swing.JFrame;

public class Main {

    public static void main(String[] args) {
        try {

            ScriptEngineManager m = new ScriptEngineManager();
            ScriptEngine rubyEngine = m.getEngineByName("jruby");
            ScriptContext context = rubyEngine.getContext();

            InputStream in = null;
            try {
                in = Main.class.getResourceAsStream("RubyClass1.rb");
                InputStreamReader ir = new InputStreamReader(in);
                Object o = rubyEngine.eval(ir);
                if (o instanceof JFrame) {
                    JFrame frame = (JFrame) o;
                    frame.setVisible(true);
                }

            } catch (ScriptException e) {
                throw e;
            } finally {
                try {
                    in.close();
                } catch (Throwable e) {
                }//swallow
            }


        } catch (Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

 

 

where in the same package you have a file named RubyClass1.rb (right now created by File|New File|Other|Ruby File in the IDE):

 

class RubyClass1 < javax.swing.JFrame

  def initialize()
  end

  def RubyClass1.new_instance()
    ret = RubyClass1.new();
    ret.setSize(400, 400)
    ret.setTitle("From Ruby")
    label = javax.swing.JLabel.new("Testing testing")
    ret.add(label)
    return ret
  end

end

ret = RubyClass1.new_instance()
return ret

 

and in it you can define classes etc or whatever and return instances, but the Ruby class isn't exactly carried over as a class that Java knows about as it is evaluated and not compiled into a class which is loaded by a classloader as a particular type, but instead you need to work with super types, so you can implement interfaces etc in Ruby and the JRuby proxy class allows you to work this way, now you could do what ever you need to setup other instances per the scripting environment, but still you probably get the point.

 

Ruby from Java

 

Jiri Kovalsky replied on Mon, 2009/01/05 - 9:21am in response to:

[quote]There is a new NetBeans Voice Of Community group that is supposed to be scanning for posts like this to make a list of community raised issues, prioritize them, and to provide the list to Sun. Sun has agreed to address at least the 30% of VOC issues [in each release?]:

http://wiki.netbeans.org/VoiceOfCommunity[/quote]

Yes, the 30% is meant for each release. And being the lead of VOC process I confirm Ryan's words that we will be interested exactly in this type of feedback coming not only via our project related channels. Thank you Alex, Ryan and Wade!

Peter Karussell replied on Mon, 2009/01/05 - 3:08pm in response to: Jiri Kovalsky

> http://wiki.netbeans.org/VoiceOfCommunity

Nice!

My favorites:

  1. An English and German spell checker like in Eclipse.
  2. Collect closed documents in a ‘trash’ (like in opera).
  3. Formatting of several files. E.g. via right clicking on a package->Tools->Formatting.
  4. Searching through keyboard shortcuts
  5. TestNG. This is very easy to setup in Eclipse ...

Maybe you could additionally initiate a (small) netbeans only competition under the community members to speed things up.

My service would be to spend at least 50 EUR for item 1 (spell checker) and 2 (trash list) to netbeans. (Where can I do this kind of support?)

 

Jiri Kovalsky replied on Tue, 2009/01/06 - 3:32am in response to: Peter Karussell

[quote]1. An English and German spell checker like in Eclipse.[/quote]

Have you tried Spellchecker plugin?

[quote]Maybe you could additionally initiate a (small) netbeans only competition under the community members to speed things up.[/quote]

Do you mean something like recent NetBeans Innovators Grant contest?

[quote]My service would be to spend at least 50 EUR for item 1 (spell checker) and 2 (trash list) to netbeans. (Where can I do this kind of support?)[/quote]

I am sorry but we don't have such donation system for popular features. But you can contribute your time and develop some of the RFEs youself or at least help setup the projects. I also suggest looking at NetBeans Support Resources overview page.

Thanks for your feedback Peter!

-Jirka

Peter Karussell replied on Tue, 2009/01/06 - 9:07am in response to: Jiri Kovalsky

[quote]Have you tried Spellchecker plugin?[/quote]

Thanks. I will try it out. When will it come into the main release?

 

[quote]I am sorry, but we don't have such donation system for popular features[/quote]

Oh, why not? I am sure a lot developers need features or want to support netbeans but do not have the time to code sth.

 

[quote]Do you mean something like recent NetBeans Innovators Grant contest?[/quote]

Yes, but money and tasks would come from community (so, a smaller community driven contest).

Duncan Kinnear replied on Mon, 2009/01/12 - 9:48pm

I really hope something has been done about the very annoying and superfluous confirmation box that appears when you debug a project. I'm talking about the "Is the server running in debug mode?" dialog.  This has to be one of the worst examples of computer-human interaction that I have seen for a long time.  As there is only one 'correct' answer to this dialog, then what is the point of popping it up at all!  It is right up there with the "Are you sure..." type questions that have luckily become a lot more scarce.

Why not make NetBeans try to determine if the server is running in debug?  If Glassfish cannot provide that kind of information then it is lacking an important feature in my opinion.

Please, whoever is listening from the NetBeans team, get rid of that idiotic message.

Peter Karussell replied on Tue, 2009/01/13 - 3:01am in response to: Duncan Kinnear

Sure, but you can simply make netbeans silent in this case ...

David Konecny replied on Tue, 2009/01/13 - 3:00pm in response to: Duncan Kinnear

I filed issue to fix this. As far as I can say this should happen only in case of debugging of Application Client project. In other project types this has been already fixed.

Duncan Kinnear replied on Tue, 2009/01/13 - 5:05pm in response to: Peter Karussell

[quote]

Sure, but you can simply make netbeans silent in this case ... 

[/quote]

 Peter, how do you "make netbeans silent in this case"?  I have not found any configuration setting for disabling this popup question.

Duncan Kinnear replied on Tue, 2009/01/13 - 5:13pm in response to: David Konecny

[quote]

As far as I can say this should happen only in case of debugging of Application Client project

[/quote]

Yes, that is how we run debug.

Our application consists of an Enterprise Application with 10 sub-projects, 4 of which are app clients.  There are no web projects at this stage as everything is rich-client based.

 Thanks for adding the issue.

David Konecny replied on Tue, 2009/01/13 - 6:12pm in response to: Duncan Kinnear

What happened is that it was fixed everywhere else for a while but overlooked in AppClient proj. Thanks for raising the problem.

Zenyk Matchyshyn replied on Thu, 2009/06/04 - 5:42am

For Ukrainian developers, short overview of Netbeans 6.5 in Ukrainian - http://www.rozrobka.com/blog/java/9.html

abu jabie replied on Tue, 2009/07/07 - 9:27pm

I confirm Ryan's words that we will be interested exactly in this type of feedback .MP3 to M4R

Comment viewing options

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