To download the PDF version of Using NetBeans IDE 5.5,
click here.
One of the main strengths of the IDE is its versatile configurability. You can customize your working environment to fit your needs and personal development style. Having all of these options can, however, make it difficult to find the exact setting you are looking for.
In this section you will learn about the following:
To configure project-level settings such as a project's properties and JDK level, see Setting Up Projects.
Setting IDE Default Settings
The main tool for configuring default settings in the IDE is the Options window. You can open the Options window by choosing Tools > Options from the main menu.
IDE settings are grouped into categories in the Options window. When you open the Options window, you are in the Basic view by default. In Basic view, you click on a category in the left pane to display the settings options in the right pane. Depending on the category, you can click on the tabs or nodes in the right pane to see additional settings.
Options dialog box
To access more advanced settings, click the Advanced Options button at the bottom of the Options window. In this Advanced view, you select a node in the left pane of the window and the properties you can modify are displayed in the right pane. An ellipsis (...) button next to the property indicates that a property editor is available for a property.
Configuring General Java Settings
The first thing you should do to configure the IDE is make sure it is using the correct Java Standard Development Kit (JDK) version. The JDK in which the IDE runs is important because it is automatically used as the platform against which all of your sources are compiled and executed. See Setting the Target JDK in a Project for details.
To see which JDK your IDE is running on, choose Help > About and click the Detail tab. The location of the JDK is listed as Java Home. By default, the IDE uses the JDK that is specified in your system's registry as the most recent. If you only have one version of the JDK installed on your computer, this is not a problem. If you have multiple JDK versions installed, it can be a good idea to configure a startup switch to explicitly specify which JDK the IDE should use. You can do so by using the
--jdkhome
JDK folder switch (for example,
--jdkhome c:\jdk1.5.0_04
) on the command line, or by specifying the JDK location in your
netbeans.conf
file.
Another important tool in defining Java settings is the Java Sources node in the Advanced view in the Options window. The Java Sources node, which is located under the Editing node, contains general settings for how the IDE handles Java source files. The following settings are available in the Java Sources node:
-
Automatic Parsing Delay.
Specifies the time (in milliseconds) between a pause in typing or moving around in the Source Editor and the time that internal parsing information is refreshed. The default is two seconds. The IDE uses the internal parser to automatically update information about the current Java source file. You can disable automatic parsing by setting this property to zero. If this property is disabled, a Java file is parsed only when the file is saved or compiled.
-
Error Annotation Limit.
Sets the amount of errors that are highlighted in the Source Editor for each open file. Set this property to zero to disable error annotation for Java files.
-
Strings Table.
Specifies the
_USER_
macro in templates and enables you to create your own macros for use in templates.
-
Show Compile Status.
If selected, displays the compile status badge on the node for a Javaclass file when that file needs to be compiled.
-
Default Encoding.
Specifies the default encoding that the IDE uses to display and save
.java
files. Type an encoding name or leave blank to use your system's default encoding. This setting does not affect the encoding used to compile classes in the IDE.
Setting Java sources properties in the Options dialog box
Working With File Types
The IDE recognizes the standard file extensions for most types of files. For example, it knows that files with the extensions
.htm
,
.html
, and
.shtml
should all be treated as HTML files. Many file types, like XML, can have nonstandard file extensions that the IDE does not recognize.
If you want to treat all files with a certain file extension as a certain type of file, go to the Options window, click the Advanced button and expand IDE Configuration > System > Object Types. The Object Types node contains all of the file types that the IDE is currently configured to work with. You can use the Extensions and MIME Types property to specify which file extensions should be treated as a given type of file.
For example, JavaHelp
ΤΜ
map files are XML documents that have a
.jhm
extension. You can treat all JavaHelp map files as XML documents by adding
.jhm
to the list of Extensions and MIME Types for the XML Object object type.
Configuring Ant Settings
You can configure additional Ant settings in the Options window by opening the Options window, selecting the Miscellaneous category in the left pane and clicking the Ant node in the right pane. You can specify the following properties:
-
Ant Home.
The installation directory of the Ant executable used by the IDE.
-
Properties.
Configures custom properties to pass to an Ant script each time you call Ant.
-
Classpath.
Specify additional JAR files and directories to be used in Ant. Type the full path in the Classpath property.
Note:
You should only add items to the Ant classpath that are needed to run custom tasks. You should not use the Classpath settings to manage the compilation or runtime classpath of your project source folders.
Enabling and Disabling IDE Functionality
NetBeans IDE is a fully modular IDE, meaning that its functionality is provided by modules that plug into the core NetBeans infrastructure. If you do not use the functionality provided by certain modules, you can turn those modules off. Turning off unused modules helps improve your IDE's startup time and performance. You can also add functionality to your IDE by downloading new modules from the Update Center.
Disabling Modules
The Module Manager is the most convenient tool for enabling and disabling modules. Disabling a module only causes the IDE to ignore the module. The module is not deleted and it can be enabled again at any time.
To open the Module Manager, choose Tools > Module Manager. The Module Manager displays all the modules registered with the IDE and if they are registered. You can enable or disable a module by selecting or deselecting the active checkbox for that module. You can uninstall a module by selecting the module in the list and clicking Uninstall. To check if new modules are available from the Update Center, click Update.
Module Manager
The Module Manager groups related modules into module groups. For example, the Java group contains all of the modules that deal with Java development. You can disable all modules in a module group by unchecking the checkbox in its Active column, or expand the module group node to disable individual modules. When only certain modules in a module group are disabled, the Active column for the group is checked [
boolean
]. When you are finished, click Close to activate your changes.
Certain modules depend on other modules to function properly. Disabling or enabling one of these modules may require you to also disable or enable the modules upon which it depends. If this is the case, the IDE displays a dialog that tells you which modules will also be disabled or enabled and asks for your confirmation.
Installing New Modules from the Update Center
You can add functionality to your IDE by downloading new modules from the NetBeans Update Center. To connect to the Update Center, choose Tools > Update Center from the main window. In the Update Center wizard, select the Update Centers that you want to connect to. Make sure that your proxy information is properly configured and that you can connect to the Internet. You can edit your proxy configuration using the Proxy Configuration button on the wizard page. Click Next when you are ready to proceed.
The second page of the wizard shows you all of the modules that are available on the Update Centers. The wizard only displays modules that are not already installed in your IDE or newer versions of modules that are already installed. Select any module to see detailed information about the module, including a description, the version number of the module on the Update Center, and the version number of the module already installed on your system.
To download a module for installation, select the module in the left pane and click the Add button. When you are ready to proceed, click the Next button to view the modules' certificates and install the modules.
Boosting NetBeans Performance
You can monitor your IDE's performance with the Memory toolbar. To view the Memory toolbar, right-click anywhere in the toolbar area and select Memory in the pop-up menu. The Memory toolbar has a slide that shows you how much of the IDE's memory is currently being used and how close it is to automatically performing garbage collection. You can manually initiate garbage collection by clicking the Memory toolbar.
You can boost NetBeans performance by adjusting the JVM switches with which you start the IDE.
Configuring IDE Startup Switches
You can use Java startup switches to configure the IDE. You can add startup switches to the IDE on the command line or by entering them in a special file called
netbeans.conf
, which is located in the
etc
folder in the NetBeans installation folder. You can enter IDE-specific startup switches and pass arguments directly to the JVM in which the IDE runs.
For example, to set the
-Xmx
(maximum heap size) for the JVM in which the IDE runs, either add the line
-J-Xmx64m
to your
netbeans.conf
file or launch the IDE from the command line by typing the following on UNIX systems:
./netbeans.sh -J-Xmx64m
or, on Windows systems, the following:
netbeans.exe -J-Xmx64m
The
netbeans.conf
file can have the various JVM switches separated either by spaces or on separate lines. Note that the JVM does not start when switches are passed that it does not understand. When this error occurs, the JVM returns a message pointing out the switch that caused the problem, as with the following example:
java -foo
Unrecognized option: -foo
Could not create the Java virtual machine.
The following table lists the available startup switches.
|
Startup Switch
|
Description
|
|
-h
--help
|
Print descriptions of common startup parameters.
|
|
--cp:p additional_classpath
|
Prefix the specified classpath to the IDE's classpath.
|
|
--cp:a additional_classpath
|
Append the specified classpath to the IDE's classpath.
|
|
--fontsize size
|
Set the font size, expressed in points, in the IDE's user interface. If this option is not used, the font size is 11 points.
|
|
--jdkhome jdk_home_dir
|
Use the specified version of the Java? 2 SDK instead of the default SDK. By default on Microsoft? Windows systems, the loader looks into the registry and uses the latest SDK available.
You should back up your user directory before you upgrade the SDK that the IDE uses. If you later need to revert to the previous JDK, switch to the backed up user directory to ensure that you do not lose any settings.
To switch the IDE's user directory, use the
-userdir
switch detailed below.
|
|
-Jjvm_flag
|
Pass the specified flag directly to the JVM.
|
|
-J-Dsun.java2d.noddraw=true
|
Prevent the use of DirectX for rendering. This switch might prevent problems that occur on some Microsoft Windows systems with faulty graphics cards.
|
|
-J-Dnetbeans.debugger.jpda.transport=dt_shmem userdir
|
Force the IDE to use the shared memory connection when starting a debugging session with the Debug > Start command. This parameter has no effect when you attach the debugger to an already running process.
|
|
--laf UI_class_name
|
Selects the given class as the IDE's look and feel. The following are two examples of look and feel classes:
-
com.sun.java.swing.plaf.motif.MotifLookAndFeel
-
javax.swing.plaf.metal.MetalLookAndFeel
|
|
--locale language[:country[:variant]]
|
Use the specified locale.
|
|
--open file
|
Open the file in the Source Editor.
|
|
--open file:line number
|
Open the file in the Source Editor at the specified line.
|
|
--userdir userdir
|
Explicitly specify the
userdir
, which is the location in which user settings are stored.
You can determine the current user directory in the About dialog box. Choose Help > About and then click the Detail Tab. The tab lists the location of the User Dir as well as other product details.
|
Tuning JVM Switches for Performance
JVMs offer a variety of standard and non-standard switches that tune memory allocation and garbage collection behavior. Some of these settings can benefit the performance of the IDE.
Note that
-X
and especially
-XX
JVM switches are officially "unsupported" because they are often JVM or JVM-vendor specific. The switches discussed in this section are available for Sun Microsystems J2SE 1.4.2 and J2SE 1.5. Users of other JVM implementations may need to remove these switches in order to run the IDE.
The following settings should produce better-than-factory setting performance on most systems. With the exception of setting the "permanent area" size, these switches have been the defaults for the IDE for some time, and should already be present in your netbeans.conf file.
-
-J-Xverify:none
This switch turns off Java bytecode verification, making classloading faster and eliminating the need for classes to be loaded during startup solely for the purposes of verification. This switch significantly improves startup time.
-
-J-Xms32m
This setting tells the Java virtual machine to set its initial heap size to 32 megabytes. By telling the JVM how much memory it should initially allocate for the heap, we save it growing the heap as the IDE consumes more memory.
-
-J-Xmx128m
This setting specifies the maximum amount of memory that the Java virtual machine should use for the heap. Placing a hard upper limit on this number means that the Java process cannot consume more memory than physical RAM available. This limit can be raised on systems with more memory - the 128 megabyte setting helps to ensure that the IDE performs tolerably on 256Mb systems.
Note:
Do not set this value to near or greater than the amount of physical RAM in your system or it will cause severe swapping during major collections.
-
-J-XX:PermSize=20m
This is a more exotic JVM switch, but one which also improves startup time. This setting sizes the "permanent area" of memory, where classes are kept. Since we know that all of IDE's classes take up a specific amount of memory, we give the JVM a hint as to how much memory it will need. This setting eliminates major garbage collection events during startup on many systems. Users of SunONE Studio or other IDEs that include more modules may want to set this number higher.
Listed below are some additional JVM switches which have either anecdotally or measurably impacted NetBeans performance on some, not all, systems. Your mileage may vary, but they may be worth a try.
-
-J-XX:CompileThreshold=100
This switch will make startup time slower, by instructing the HotSpot JVM to compile many more methods down to native code sooner than it otherwise would. The reported result is snappier performance once the IDE is running, since more of the UI code will be compiled rather than interpreted. This value represents the number of times a method must be called before it will be compiled.
-
-J-XX:+UseConcMarkSweepGC -J-XX:+UseParNewGC
Try these switches if you are having problems with intrusive garbage collection pauses. This switch causes the JVM to use different algorithms for major garbage collection events (also for minor collections, if run on a multiprocessor workstation), ones which do not "stop the world" for the entire garbage collection process. If you are using the PermSize switch, you should also add the line
-J-XX:+CMSClassUnloadingEnabled
to your
netbeans.conf
file so that class unloading is enabled (it isn't by default when using this collector).
Note:
It is unclear as yet if this collector helps or hurts performance on uniprocessor machines.
-
-J-XX:+UseParallelGC
Some tests have shown that, at least on systems fairly well equipped with memory, the durations of minor garbage collections is halved when using this collection algorithm, on uniprocessor systems. Note that this is paradoxical - this collector is designed to work best on multiprocessor systems with gigabyte heaps. No data is available on its effect on major garbage collections. Note: this collector is mutually exclusive with
-J-XX:+UseConcMarkSweepGC
. The measurements supporting the use of this algorithm can be found on the performance web site.