Wednesday, 14 December 2011

Netbeans Tips & Tricks

Contents

Netbeans 7.0.1. doesn't validate jdk 7.0 syntax in editor

Netbeans 7.0.1. doesn't start

How to automatically use a License in your new java files

Changing indentation style


Netbeans 7.0.1. doesn't validate jdk 7.0 syntax in editor

For example, editor complains about: "try-with-resources is not supported in -source 1.6 (use -source 7 or higher to enable try-with-resources)" in a try-with-resources block.

Right click project. Properties. Sources. Source-binary->jdk7. No problems after that.

Of course, there's still the problem that the new syntax in the JSP pages doesn't work.

Jk7 doesn't work with jsp pages yet, see http://java.net/jira/browse/GLASSFISH-17429 .


Netbeans 7.0.1. doesn't start

I just downloaded Netbeans 7.0.1 from http://www.oracle.com/technetwork/java/javase/downloads.

It didn't work.

No output on the console, either.

However, I was able to run Netbeans correctly from the root account.

It turns out that I had the settings of a previous version of Netbeans in my homedir. To wit:

  • .netbeans/
  • .netbeans-derby/
  • .netbeans-registration/

After removing said settings, netbeans started properly and created the setting directory .netbeans.

Hope it helps someone.


How to automatically use a License in your new java files

Add project.license=gpl30 (for example) to your project.properties file in nbproject directory of your project.


But there are easier ways to do it in Netbeans 7.4. Choose Project properties, select "License Headers" and just set the Global license to for example General Public License 3.0

Changing indentation style

To change editor settings.

Click the Tools > Options menu item.

In the icon display, click Editor.

In the right panel, select the category "Tabs and Indents" tab.

If it isn't already done, set the following:

Statement continuation Indent: 8

Number of Spaces per Indent: 4

Check Expand Tabs to Spaces.

In the right panel, select the category "Braces" tab.

If you like the Allman indentation style (like me), check the "New Line" for a Class declaration, Method declaration and Other.

References

NetBeans IDE
http://leepoint.net/notes-java/tools/netbeans/netbeans.html
Project-Level License Settings in NetBeans IDE 6.0
http://blogs.oracle.com/geertjan/entry/project_level_license_settings_in

No comments:

Post a Comment