Java IDEs have come a long way since the days of JBuilder (though JBuilder seemed like a welcome advance at the time). Today's Java IDEs (such as NetBeans, Eclipse, IntelliJ IDEA, and JDeveloper) are very advanced tools that most Java developers embrace for writing significant Java code. As advanced as these IDEs are, they all still have their own quirks and each seems better and easier to use when one understands some key tips (or "tricks") to using that IDE more efficiently. In this post, I look at some tips I have found useful when using NetBeans.
Disabling Automatic ScanningA problem that can be especially onerous when using NetBeans on a large code base with many related projects open is the occasionally too-frequent automatic scanning that NetBeans performs. This is supposed to only occur intermittently and its intention is good, but sometimes the intended behavior's value is worth less than the performance-degrading cost justifies. Fortunately, this option can be disabled when its cost is greater than its benefit. In the NetBeans for PHP blog post Enable auto-scanning of sources - Scan for External Changes, Petr Pisl covers how to do this in NetBeans 6.9.
This feature is also supported in NetBeans 7.1 as shown in the following screen snapshot (window shown is accessible by selecting Tools ⇒ Options ⇒ Miscellaneous ⇒ Files).
If the benefits of automatic scanning are desired (because, for example, multiple people are changing source code underneath each other frequently or because different editors are being used on the same versions of files), but less of it is wanted, another tip is to reduce the number of NetBeans projects and files that are open in NetBeans.
Controlling Level of NetBeans HintsNetBeans's Java hints can aid the Java developer in improving and modernizing his or her Java code. The hints cover topics as diverse as performance, safety, conciseness, coding standards, likely bugs, latest JDK standards, and best practices. I do not cover these useful hints in more detail here because I've already covered them in multiple previous posts. I introduced NetBeans hints and how to enable them , configure them as warnings or errors, and introduced seven of the most important hints in my blog post Seven Indispensable NetBeans Java Hints. In the blog post Seven NetBeans Hints for Modernizing Java Code, I discussed seven more hints that are useful for bridging legacy Java code forward to use the best features of newer SDKs (J2SE 5, Java SE 6, and Java SE 7). My post Creating a NetBeans 7.1 Custom Hint demonstrates writing custom hints to further expand NetBeans hinting capability beyond the out-of-the-box hints.
Setting Source/Target JDK AppropriatelyIn the blog post Specifying Appropriate NetBeans JDK Source Release, I looked at several advantages of setting the JDK level for the NetBeans projects' source/target JDKs appropriately. This can make a major difference for developers using JDK 7 as it helps the hints covered in the previous tip to show areas where pre-JDK 7 code can be migrated to JDK 7 constructs. However, even developers using JDK 6 or JDK 5 can find value to having this set appropriately. The appropriate setting not only advertises features that are available, but it also prevents developers from mistakenly using newer versions when they are not yet available in the actual version of code the developer should be using. NetBeans will warn the developer that certain features are not available for that JDK setting, so it is important to have it set properly.
Leveraging NetBeans Keyboard CommandsWhether it's vi, emacs, Eclipse, NetBeans, or any other editor, the masters of the respective editors know and frequently use keyboard commands to get work done quickly. NetBeans offers so many keyboard-based commands that it's difficult to summarize them. However, some good starting points include Highlights of NetBeans IDE 7.0 Keyboard Shortcuts and Code Templates, NetBeans Tips and Tricks, Keyboard Shortcuts I Use All the Time, NetBeans IDE Keyboard Shortcuts, and NetBeans Shortcut Keys. NetBeans even supports Eclipse key bindings!
Hiding Clutter and Noise with Code FoldingMy preference is to have as clean of code as possible. Sometimes, however, I am forced to deal with code that has a lot of unimportant junk or noise in it. In such cases, NetBeans's code folding support is welcome because I can hide that noise. It would obviously better if I could remove the unnecessary noise and code folding can be abused, but I am appreciative of the feature when it's my only option for reducing clutter and noise so that I can focus on what matters. I discussed NetBeans code folding in further detail in the post NetBeans Code Folding and the Case for Code Folding.
Other NetBeans TipsThere are numerous other useful NetBeans tips available online.
Roman Strobl's NetBeans Quick TipsIn the blog he maintained while working at Sun Microsystems, Roman Strobl wrote several "NetBeans Quick Tip" posts (although dated [mid-2000s], several of these are still applicable):
- NetBeans Quick Tip #1 - Setting Target JDK.
- NetBeans Quick Tip #2 - Generating Getters and Setters
- NetBeans Quick Tip #3 - Increasing Font Size
- NetBeans Quick Tip #4 - Extending the Build Process
- NetBeans Quick Tip #5 - EOL Sweeper
- NetBeans Quick Tip #6 - Abbreviations in Editor
- Quick Tip #7 - Macros in Editor
- NetBeans Quick Tip #8 - Using Custom Folds
- Quick Tip #9 - Better Responsivenes of Error Marks and Hints
- NetBeans Quick Tip #10 - Diffing Two Files
- NetBeans Quick Tip #11 - How to Save As...
- Netbeans Quick Tip #12 - Fast Navigation to Methods and Fields
- NetBeans Quick Tip #13 - Define a Shortcut for Ant Target
- NetBeans Quick Tip #14 - Accessing Files Outside Projects
- NetBeans Quick Tip #15 - Adding Multiple Components with Matisse
- NetBeans Quick Tip #16 - Using Dependent Projects
- NetBeans Quick Tip #17 - Faster Building of Projects with Dependencies
- NetBeans Quick Tip #18: What to Do when Things Go Wrong?
- NetBeans Quick Tip #19 - Positioning without Guidelines in Matisse
- NetBeans Quick Tip #20 - Killing Processes
- NetBeans Quick Tip #21 - Achieving Same Size
- NetBeans Quick Tip #22 - Using Matisse's Connection Manager
- NetBeans Quick Tip #23 - Changing Code in Blue Guarded Blocks
- NetBeans Quick Tip #24 - Correct Javadoc
- NetBeans Quick Tip #25 - Case Insensitive Code Completion
- NetBeans Quick Tip #26 - Short Package Names
- NetBeans Quick Tip #27 - Implementing Abstract Methods
- NetBeans Quick Tip #28 - Configuring Derby Database in NetBeans 5.0
- NetBeans Quick Tip #29 - Monitoring HTTP Communication
- NetBeans Quick Tip #30 - When GroupLayout Fails
- NetBeans Quick Tip #31 - Changing the Look and Feel
- NetBeans Quick Tip #32 - Faster and More Stable Ruby Support
- NetBeans Quick Tip #33 - Show Error Using Keyboard
- Keyboard Shortcuts I Use All the Time
- NetBeans Community Docs- Tips And Tricks
- Dumb Coder NetBeans Tips
- Gephi NetBeans Tips
- Tips and Tricks of NetBeans
- Netbeans Quick Tip: How to use tabs not spaces
- Netbeans Tips and Tricks
- Can I Diff Two Files Outside Version Control?
What is your favorite NetBeans tip or trick?
3 comments:
The Versioning support for any files. for example i am using SVN checkout source code. With NB IDE i can track inline code changes easily.
One of the features of NetBeans that I considered including in this post, but did not include because I realized I don't use it as much as the others, is NetBeans's ability to present code in HTML. Adam Bien has recently posted on this feature in the post Pretty Printing Java Source as HTML. Another idea is to print/save the HTML output as PDF. This is such a nice NetBeans feature that even Eclipse wants it!
The blog post Ten Time-Savers in NetBeans lists ten handy features of NetBeans including typing shortcuts, commenting out a block of code (Ctrl+Shift+C), global replace (Ctrl+R), automatic formatting (Ctrl+Alt+F), determining project hosting a file (Ctrl+Shift+1), closing all open files (Ctrl+Shift+F4), fixing import statements automatically (Ctrl+Shift+I), Javadoc auto-completion (Ctrl+Space), code insertion (Alt+Insert), and NetBeans's nifty differencing tool [Tools->Diff as shown in my post NetBeans 7.2: Generating (Introduce) Local Extensions].
The post is well worth checking out as it has brief commentary and numerous illustrations (screen snapshots) of each tip in action.
Post a Comment