Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Monday, November 19, 2007

Settings in java NetBeans you might want to change

Indentation style settings
To change editor settings.
  • Click the Tools > Options menu item.
  • In the icon display on the left, click Editor.
  • In the right panel, select the Indentation 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.
    • If you like the Allman indentation style, check the Add New Line before Brace box.
Modifying the initial template for Java classes
When NetBeans creates one of several different types of initial files for you, it uses a template. Edit one or more of these templates so the files start with the text you want, eg, comments with your name, etc.
  • Select the Tools > Template Manager menu item. This displays a dialog box.
  • Expand the Java Classes tree folder in the dialog box. [Ignore all the other folders.]
  • Select Java Main Class or Java Class because these are what you will be using. Click the Open in Editor button at the bottom of the dialog box.
  • Edit the file to look like what you want your initial file to look like. I typically change the comments to my preferred style. The text contains predefined symbols, like __DATE__, which will be expanded as appropriate when the template is used.
  • Save it.
Changing to generic, type-safe, data structures. Deprecation warnings.
When compiling a program that uses non-generic data structures, it's possible to accidentally add an element of the wrong type. To alert you to places where this might be a problem, add
  • Right click on the project in the Projects panel at the left.
  • Select Properties at the bottom of the popup menu.
  • Click on Build > Compiling in the left panel.
  • To enable the most useful compiler warnings, in the Additional Compiler Options, put
  • -Xlint:all -Xlint:-serial
    -Xlint:unchecked <[>Click OK. This turns on all warnings, but turns off warnings about not making your class serializable, which is really fine for most cases.
  • Also click Report Used of Deprecated APIs to be informed about obsolete library features you are using.
Turning runtime assertion checking on
  • Right click on the project icon in the Project panel at the left.
  • Select Properties at the bottom of the drop-down menu.
  • Click on the Run choice in the left panel.
  • In the VM Options text field at the right, enter "-ea" (without the quotes). "ea" stands for enable assertions. VM stands for Virtual Machine in this case, not virtual memory.

No comments:

Post a Comment

Archives