Difference between revisions of "NetBeans"
Line 23: | Line 23: | ||
Accept all license terms for both Java & jUnit. | Accept all license terms for both Java & jUnit. | ||
<gallery> | <gallery> | ||
− | File:Netbeans install 01.png| | + | File:Netbeans install 01.png|Installation step 01 |
</gallery> | </gallery> | ||
Let the IDE check for update in background. | Let the IDE check for update in background. | ||
<gallery> | <gallery> | ||
− | File:Netbeans install 02.png| | + | File:Netbeans install 02.png|Installation step 02 |
</gallery> | </gallery> | ||
Line 60: | Line 60: | ||
** enable 'remove trailing whitespaces from: 'ALL LINES' | ** enable 'remove trailing whitespaces from: 'ALL LINES' | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 01.png| | + | File:Netbeans config 01.png|Remove trailing spaces |
</gallery> | </gallery> | ||
Line 66: | Line 66: | ||
** Click on the 2 import checkboxes | ** Click on the 2 import checkboxes | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 02.png| | + | File:Netbeans config 02.png|Adjust import |
</gallery> | </gallery> | ||
Line 81: | Line 81: | ||
Tools > Options > Editor > Code Completion | Tools > Options > Editor > Code Completion | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 03.png| | + | File:Netbeans config 03.png|Code completion |
</gallery> | </gallery> | ||
Line 88: | Line 88: | ||
Tools > Options > Miscellaneous > Terminal > Increase history to, at least, 80 000 | Tools > Options > Miscellaneous > Terminal > Increase history to, at least, 80 000 | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 04.png| | + | File:Netbeans config 04.png|Terminal history |
</gallery> | </gallery> | ||
Line 97: | Line 97: | ||
Tools > Java > Ant | Tools > Java > Ant | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 08.png| | + | File:Netbeans config 08.png|ANT configuration |
</gallery> | </gallery> | ||
Line 109: | Line 109: | ||
* Adjust JavaDoc and Source retrieval. I advise you to use 1st project only | * Adjust JavaDoc and Source retrieval. I advise you to use 1st project only | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 05.png| | + | File:Netbeans config 05.png|Maven JavaDoc |
</gallery> | </gallery> | ||
Line 119: | Line 119: | ||
* Set Properties: skipTests | * Set Properties: skipTests | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 06.png| | + | File:Netbeans config 06.png|Maven SkipTests |
</gallery> | </gallery> | ||
Line 132: | Line 132: | ||
If you have installed the JavaFX Scene Builder you can specify the link here: | If you have installed the JavaFX Scene Builder you can specify the link here: | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 07.png| | + | File:Netbeans config 07.png|JavaFX config |
</gallery> | </gallery> | ||
Line 147: | Line 147: | ||
* JaCoCo Library | * JaCoCo Library | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 09.png| | + | File:Netbeans config 09.png|JaCoco code Coverage |
</gallery> | </gallery> | ||
Line 165: | Line 165: | ||
* add a new update center | * add a new update center | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 10.png| | + | File:Netbeans config 10.png|Checkstyle install 01 |
</gallery> | </gallery> | ||
* Just fill up the form: | * Just fill up the form: | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 11.png| | + | File:Netbeans config 11.png|Checkstyle install 02 |
</gallery> | </gallery> | ||
For NetBeans 7.x the URL is: http://www.sickboy.cz/checkstyle/autoupdate/autoupdate-3.xml | For NetBeans 7.x the URL is: http://www.sickboy.cz/checkstyle/autoupdate/autoupdate-3.xml | ||
Line 177: | Line 177: | ||
* Install checkstyle | * Install checkstyle | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 12.png| | + | File:Netbeans config 12.png|Checkstyle install 03 |
</gallery> | </gallery> | ||
Line 185: | Line 185: | ||
Set your configuration file | Set your configuration file | ||
<gallery> | <gallery> | ||
− | File:Netbeans config 13.png| | + | File:Netbeans config 13.png|Checkstyle usage |
</gallery> | </gallery> | ||
Line 198: | Line 198: | ||
====View packages as tree==== | ====View packages as tree==== | ||
Right click on the Projects tab > View Java Packages as > Reduced Tree or Tree | Right click on the Projects tab > View Java Packages as > Reduced Tree or Tree | ||
− | > | + | <gallery> |
+ | File:Netbeans custom 1.png|Tree packages | ||
+ | </gallery> | ||
Line 237: | Line 239: | ||
* Choose your server location | * Choose your server location | ||
<gallery> | <gallery> | ||
− | File:Netbeans GF.png| | + | File:Netbeans GF.png|Netbeans Glassfish |
</gallery> | </gallery> | ||
Line 249: | Line 251: | ||
* Choose your location and set a Tomcat user, as defined in $Tomcat/conf/tomcat-users.xml | * Choose your location and set a Tomcat user, as defined in $Tomcat/conf/tomcat-users.xml | ||
<gallery> | <gallery> | ||
− | File:Netbeans tomcat7.png| | + | File:Netbeans tomcat7.png|Netbeans Tomcat |
</gallery> | </gallery> | ||
Click finish | Click finish |
Revision as of 10:57, 25 November 2013
Contents
Installation
Download NetBeans from the official website: https://netbeans.org/
Take the NetBeans Java EE version.
Linux
- Download the NetBeans script
- Make the script executable and run it
chmod 755 netbeans-7.4-javaee-linux.sh
./netbeans-7.4-javaee-linux.sh
Installation process
On installation start you can choose to install or not some servers:
- Glassfish 4 = full JEE server. It provides EJB, JSF and all the JEE stack. Your application can rely on it.
- Tomcat 7 = servlet container. It can only display JSP. You have to provide the other library into your application.
[ I like to install them separately ]
Accept all license terms for both Java & jUnit.
Let the IDE check for update in background.
JDK settings
Adjust NetBeans' JDK
When you upgrade your JDK you might have a NetBeans error at startup. You have to edit the core configuration file.
- Close NetBeans
- edit: $NetBeans\etc\netbeans.conf
netbeans_jdkhome="C:\Program Files\Java\jdk1.7.0_21"
- Adjust default JDK path
Register new JDK into the application
Start NetBeans, go to “Tools > Java Platforms”
- Add the new JDK
- You can also remove the old ones that don’t exist anymore
Configuration
Formatter
Remove trailing spaces and unused imports
Tools > Options > Editor > OnSave
- All languages
- enable 'remove trailing whitespaces from: 'ALL LINES'
- Java
- Click on the 2 import checkboxes
Code generation
Tools > Options > Editor > Formatting
- Language: Java
- Category: code generation
Display JavaDoc with code completion
To improve development comfort you can display the JavaDoc along with Code Completion.
Tools > Options > Editor > Code Completion
Increase terminal history
Tools > Options > Miscellaneous > Terminal > Increase history to, at least, 80 000
Ant home
If you have your own ANT installation you can use it instead of the default one.
Tools > Java > Ant
Maven configuration
Plugin configuration
Tools > Options > Java > Maven
- adjust installation path
- Adjust JavaDoc and Source retrieval. I advise you to use 1st project only
Add Maven SkipTests build
Tools > Options > Java > Maven > Edit Global Custom Goal Definitions
- ADD new "skipTests"
- Goals: clean install
- Set Properties: skipTests
Then, right click on project name > Custom > skipTests
JavaFX Scene Builder
Download JavaFX scene builder: http://www.oracle.com/technetwork/java/javafx/downloads/index.html
Tools > Options > Java > JavaFX
If you have installed the JavaFX Scene Builder you can specify the link here:
Plugins
Jacoco code coverage
Tools > Plugins > Available plugins Install:
- TikiOne JaCoCoverage Plugin
- TikiOne JaCoCo Reporting Libraries
- TikiOne JaCoCoverage Libraries
- JaCoCo Library
Click on install, accept the license, trust the packages and restart NetBeans.
!! For the plugin to work, you must use the default report file 'jacoco.exec' !!!
Adjust your project’s Maven Surefire plugin settings accordingly
Checkstyle
Official Web site: http://www.sickboy.cz/checkstyle/download.html
Installation
Tools Menu > Plugins > Settings
- add a new update center
- Just fill up the form:
For NetBeans 7.x the URL is: http://www.sickboy.cz/checkstyle/autoupdate/autoupdate-3.xml
- Now go to Tools > Plugins > Available plugins
- Install checkstyle
Checkstyle configuration
Tools > Options > Miscellaneous > Checkstyle
Set your configuration file
Shortcuts and Customization
Shortcuts
Official list of NetBeans shortcuts: https://netbeans.org/project_downloads/www/shortcuts.pdf
View packages as tree
Right click on the Projects tab > View Java Packages as > Reduced Tree or Tree
Where is the current file?
This is Eclipse “find in Editor”
You have to use the shortcuts: Ctrl + Shift + 1
Find usage
This is Eclipse Call Hierarchy
Use “ Alt + F7 ” shortcut
Generate Getters and Setters
Use “ Alt + insert ” shortcut
Maximize / Minimize code window
Use the “ Shift + Esc ” shortcut
Useful windows
This is like the Eclipse views
- Window > Action item
- Window > Output > { Output + Test Results + Search Results }
- Window >Navigating > Navigator
- Window > Other > JavaDoc
Server configuration
This is not necessary if you installed Glassfish and/or Tomcat with NetBeans.
GlassfishJEE server
Tools > Server > Add a new server
- Select Glassfish server
- Choose your server location
Let the default settings and click finish
Apache Tomcat
Tools > Servers > Add Server
- Select Apache Tomcat
- Choose your location and set a Tomcat user, as defined in $Tomcat/conf/tomcat-users.xml
Click finish