1.2 Explain the purpose of the user directory and the netbeans.conf file and how these can be used to configure the IDE.
User directory.
Directories in Netbeans: Install, User and Projects
The following are the three (major) directories used by Netbeans:
- Installation Directory. The directory where ide is installed and run from.
- User Directory. The directory where user settings are stored.
- Projects directory. The directory where a netbeans project is stored. Each project has its own project directory.Introduced since nb4.
What is User Directory ?userdir is the directory where NetBeans stores user configuration data such as window layouts, editor settings, menu and toolbar customizations and various module settings.
Per default, it is a (hidden) directory called .netbeans stored in the user's home directory. The home directory is (=${HOME}= on Unix-like systems, C:\Documents and Settings\<user> on Windows) under .netbeans/<nb-version>. As the name suggests, userdir is unique per user.
Modules can use userdir to store persistent data (for example, source and library file databases and indexes). Also, additional modules installed by the user are typically stored in the userdir.
To find out the exact userdir location go to the main menu, invoke the NetBeans | About NetBeans.
- How to find the current user directory? Run the ide and open the about box (Help | About) and switch to 'Details' tab. You will notice an entry for userdir.
- If you are unable to run the ide even: Check the [ideinstalldir]/etc/*.conf file. There should be entry called "netbeans_default_userdir".
- Sometimes the user directory may get corrupted resulting in strange behaviour (like settings not getting saved etc). In such cases:
o Run the ide with a fresh userdir as "[netbeans_install_dir]/bin/netbeans.exe --userdir [path_to_non_existent_dir]". As an example, [path_to_non_existent_dir] can be "c:\temp\myuserdir". The ide will create the [path_to_non_existent_dir] and use it as the user directory for that session.
o Run the IDE and note down the usedir from the Details tab in the About box as specified in the blog. Close the IDE. Open the Windows Explorer and rename the [userdir] to something like [userdir].bkp. Run the IDE via the standard desktop icon or start menu item. The IDE will find that the [userdir] does not exist and will create [userdir]. If you do not wish to save the current user directory, simply delete the directory. The ide will recreate the directory upon next startup.
o Modify the user directory value in the conf file to permanantly set the userdir to a different directory.
* It is possible to have several user directories with different settings and to switch between them using "--userdir" option while invoking the ide.
In addition to the above directories, some modules use the user's home directory (${HOME}) to store some settings. These are usually done when a module needs to store information that is valid no matter what the current user directory may be (the same ide install can be run with different user directories with '--userdir' parameter). The module could of course store this in the ide-install directory; but not all users may have writable access to the ide-install directory. So, to solve the problem of storing data that is not really user-specific but cannot be written to ide-install directory due to permission issues, modules may choose to store data in ${HOME} directory.
NetBeans conf.file NetBeans conf.file located at IDE-HOME/etc/netbeans.conf is used to pass startup parameters to the IDE launcher. The launcher reads this file prior to parsing the command-line options, including any parameters you have added.
The following table defines the switches you can use with the IDE.
--help (or -h)
Prints descriptions of common startup parameters. |
--jdkhome jdk-home-dir
Uses the specified version of the JavaTM 2 JDK instead of the default
JDK. By default on Microsoft Windows systems, the IDE's launcher looks
into the registry and uses the latest JDK available.
You should back up your user directory before you upgrade the JDK 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 that is detailed below. |
--cp:p additional-classpath
Prefixes the specified class path to the IDE's class path. |
--cp:a additional-classpath
Appends the specified class path to the IDE's class path. |
--open file
Opens the file in the Source Editor. |
--open file:line number
Opens the file in the Source Editor at the specified line. |
--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 |
--fontsize size
Sets the font size, expressed in points, in the IDE's user interface. If this option is not used, the font size is 11 points. |
--locale language[:country[:variant]]
Activates the specified locale. |
--userdir userdir
Explicitly specifies the user directory, which is the location where user settings are stored.
If this option is not used in UNIX® environments, the user directory is
set in the HOME directory by default. If this option is not set on
Microsoft Windows systems, the user directory is the one you specified
when you first launched the IDE.
You can determine the current user directory in the About dialog box.
Choose Help > About. Then click the Detail Tab and look at the User
Dir field. |
-Jjvm-flags
Passes the specified flags directly to the JVM software. |
-J-Dsun.java2d.noddraw=true
Prevents the use of DirectX for rendering. This switch might prevent
problems that occur on some Microsoft Windows systems with faulty
graphics cards. |
-J-Dorg.netbeans.spi.java.project.support.ui.packageView.USE_TREE_VIEW=true
Displays packages in the Project window in a directory-based view rather than a package-based view.
When adding startup switches, you can break options into multiple lines |
-- Wagner.