Difference between revisions of "NetBeans"

 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[Category:Development]]
 +
 
===Installation===
 
===Installation===
  
Line 9: Line 11:
 
* Make the script executable and run it
 
* Make the script executable and run it
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
chmod 755 netbeans-7.4-javaee-linux.sh
+
chmod 755 netbeans-8.0-javaee-linux.sh
./netbeans-7.4-javaee-linux.sh
+
./netbeans-8.0-javaee-linux.sh
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
====Installation process====
 
====Installation process====
 
On installation start you can choose to install or not some servers:
 
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.
 
*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.
+
*Tomcat 8 = servlet container. It can only display JSP. You have to provide the other library into your application.
  
 
[ I like to install them separately ]
 
[ I like to install them separately ]
  
 
Accept all license terms for both Java & jUnit.
 
Accept all license terms for both Java & jUnit.
>> netbeans install 01 <<
+
[[File:Netbeans install 01.png|none|Installation step 01]]
  
 
Let the IDE check for update in background.
 
Let the IDE check for update in background.
>> netbeans install 02 <<
+
[[File:Netbeans install 02.png|none|Installation step 02]]
  
 
===JDK settings===
 
===JDK settings===
 +
 
====Adjust NetBeans' JDK====
 
====Adjust NetBeans' JDK====
 
When you upgrade your JDK you might have a NetBeans error at startup. You have to edit the core configuration file.
 
When you upgrade your JDK you might have a NetBeans error at startup. You have to edit the core configuration file.
Line 35: Line 39:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
* Adjust default JDK path
 
* Adjust default JDK path
 +
  
 
====Register new JDK into the application====
 
====Register new JDK into the application====
 
Start NetBeans, go to “Tools > Java Platforms”
 
Start NetBeans, go to “Tools > Java Platforms”
 
* Add the new JDK
 
* Add the new JDK
* Remove the old one that doesn’t exist anymore
+
* You can also remove the old ones that don’t exist anymore
 +
 
  
 
===Configuration===
 
===Configuration===
 +
====Look and feel====
 +
Tools > Options > Appearance > "look and feel"
 +
 +
The *Nimbus* look is a bit more friendly for your eyes. The gray background is better :)
 +
 +
 +
====Fonts & Colors====
 +
Tools > Options > "Fonts and colors"
 +
 +
The *Norway Today* theme is a high contrast theme.
 +
 +
 
====Formatter====
 
====Formatter====
 
=====Remove trailing spaces and unused imports=====
 
=====Remove trailing spaces and unused imports=====
Line 48: Line 66:
 
* All languages
 
* All languages
 
** enable 'remove trailing whitespaces from: 'ALL LINES'
 
** enable 'remove trailing whitespaces from: 'ALL LINES'
netbeans_config_01.png
+
[[File:Netbeans config 01.png|none|Remove trailing spaces]]
  
 
* Java
 
* Java
 
** Click on the 2 import checkboxes
 
** Click on the 2 import checkboxes
netbeans_config_02.png
+
[[File:Netbeans config 02.png|none|Adjust import]]
 
   
 
   
 +
 
=====Code generation=====
 
=====Code generation=====
 
Tools > Options > Editor > Formatting
 
Tools > Options > Editor > Formatting
 +
* Language: '''All languages'''
 +
* Category: ''Tabs and indents''
 +
 +
[[Netbeans_format_all_languages_p1.png|none|Margins]]
 +
 
* Language: Java
 
* Language: Java
 
* Category: code generation
 
* Category: code generation
Line 62: Line 86:
 
====Display JavaDoc with code completion====
 
====Display JavaDoc with code completion====
 
To improve development comfort you can display the JavaDoc along with Code Completion.
 
To improve development comfort you can display the JavaDoc along with Code Completion.
 +
 
Tools > Options > Editor > Code Completion
 
Tools > Options > Editor > Code Completion
netbeans_config_03.png
+
[[File:Netbeans config 03.png|none|Code completion]]
  
+
 
Increase terminal history (= console output buffer)
+
====Increase terminal history====
 
Tools > Options > Miscellaneous > Terminal > Increase history to, at least, 80 000
 
Tools > Options > Miscellaneous > Terminal > Increase history to, at least, 80 000
netbeans_config_04.png
+
[[File:Netbeans config 04.png|none|Terminal history]]
 +
 
 +
 
 +
====Ant home====
 +
If you have your own ANT installation you can use it instead of the default one.
 +
 
 +
Tools > Java > Ant
 +
[[File:Netbeans config 08.png|none|ANT configuration]]
 +
 
 
   
 
   
Maven configuration
+
 
Plugin configuration
+
===Maven configuration===
 +
 
 +
====Plugin configuration====
 
Tools > Options > Java > Maven
 
Tools > Options > Java > Maven
·      adjust installation path
+
* adjust installation path
·      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
netbeans_config_05.png
+
[[File:Netbeans config 05.png|none|Maven JavaDoc]]
 +
 
  
Add Maven SkipTests build
+
====Add Maven SkipTests build====
 
Tools > Options > Java > Maven > Edit Global Custom Goal Definitions
 
Tools > Options > Java > Maven > Edit Global Custom Goal Definitions
·      ADD new "skipTests"
+
* ADD new "skipTests"
·      Goals: clean install
+
* Goals: clean install
·      Set Properties: skipTests
+
* Set Properties: skipTests
netbeans_config_06.png
+
[[File:Netbeans config 06.png|none|Maven 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
  
Then, right click on project name > Custom > skipTests
 
JavaFX Scene Builder
 
http://www.oracle.com/technetwork/java/javafx/downloads/index.html
 
 
Tools > Options > Java > JavaFX
 
Tools > Options > Java > JavaFX
 +
 
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:
netbeans_config_07.png
+
[[File:Netbeans config 07.png|none|JavaFX config]]
  
Add other JDKs
 
Sometimes it’s useful to add an old JDK for legacy projects.
 
Tools > Java Platforms > Add
 
Just follow the wizard.
 
To add a JDK just choose the JDK folder, example:  C:\Program Files\Java\jdk1.7.0_25
 
 
Ant home
 
If you have your own ANT installation you can use it instead of the default one.
 
Tools > Java > Ant
 
 
 
 
 
 
netbeans_config_08.png
 
  
  
+
===Plugins===
NetBeans # plugins
+
 
Jacoco code coverage
+
====Eclipse code formatter====
 +
Tools > Plugins > Available plugins
 +
Install "Eclipse code formatter"
 +
 
 +
Then, after the installation go to: Tools > Options > Java > Eclipse formatter
 +
just ENABLE the Eclipse formatter and set a configuration file.
 +
Note: don't forget to click ''format on save'' at the bottom.
 +
 
 +
====Jacoco code coverage====
 
Tools > Plugins > Available plugins
 
Tools > Plugins > Available plugins
 
Install:
 
Install:
·      TikiOne JaCoCoverage Plugin
+
* TikiOne JaCoCoverage Plugin
·      TikiOne JaCoCo Reporting Libraries
+
* TikiOne JaCoCo Reporting Libraries
·      TikiOne JaCoCoverage Libraries
+
* TikiOne JaCoCoverage Libraries
·      JaCoCo Library
+
* JaCoCo Library
netbeans_config_09.png
+
[[File:Netbeans config 09.png|none|JaCoco code Coverage]]
  
 
Click on install, accept the license, trust the packages and restart NetBeans.
 
Click on install, accept the license, trust the packages and restart NetBeans.
F For the plugin to work, you must use the default report file 'jacoco.exec' !!!
+
 
    >> Adjust your project’s Maven Surefire plugin settings accordingly
+
!! For the plugin to work, you must use the default report file 'jacoco.exec' !!!
 +
 
 +
Adjust your project’s Maven Surefire plugin settings accordingly
 
            
 
            
  
+
====Checkstyle====
Checkstyle
 
 
Official Web site: http://www.sickboy.cz/checkstyle/download.html
 
Official Web site: http://www.sickboy.cz/checkstyle/download.html
Add update center
+
 
Checkstyle plugin is not available from the official list. You have to download it manualy.
+
=====Installation=====
 +
 
 
Tools Menu > Plugins > Settings
 
Tools Menu > Plugins > Settings
add a new update center
+
* add a new update center
netbeans_install_10.png
+
[[File:Netbeans config 10.png|none|Checkstyle install 01]]
  
Just fill up the form:
+
* Just fill up the form:
netbeans_install_11.png
+
[[File:Netbeans config 11.png|none|Checkstyle install 02]]
 +
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
+
* Now go to Tools > Plugins > Available plugins
Install plugin
+
* Install checkstyle
Now go to Tools > Plugins > Available plugins
+
[[File:Netbeans config 12.png|none|Checkstyle install 03]]
Install checkstyle
 
netbeans_config_12.png
 
  
Checkstyle configuration
+
=====Checkstyle configuration=====
 
Tools > Options > Miscellaneous > Checkstyle
 
Tools > Options > Miscellaneous > Checkstyle
 +
 
Set your configuration file
 
Set your configuration file
netbeans_config_13.png
+
[[File:Netbeans config 13.png|none|Checkstyle usage]]
  
+
 
NetBeans # shortcuts and Customization
+
 
Official list of NetBeans shortcuts
+
===Shortcuts and Customization===
https://netbeans.org/project_downloads/www/shortcuts.pdf
+
 
View packages as tree
+
====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
 
Right click on the Projects tab > View Java Packages as > Reduced Tree or Tree
netbeans_custom_1.png
+
[[File:Netbeans custom 1.png|none|Tree packages]]
Where is the current file? (= Eclipse “find in Editor”)
+
 
 +
 
 +
====Where is the current file?====
 +
This is Eclipse “find in Editor”
 +
 
 
You have to use the shortcuts:    Ctrl + Shift + 1   
 
You have to use the shortcuts:    Ctrl + Shift + 1   
Find usage (= Eclipse Call Hierarchy)
+
 
 +
====Find usage====
 +
This is Eclipse Call Hierarchy
 +
 
 
Use “ Alt + F7 ” shortcut
 
Use “ Alt + F7 ” shortcut
Generate getters and setters
+
 
 +
====Generate Getters and Setters====
 
Use “ Alt + insert ” shortcut
 
Use “ Alt + insert ” shortcut
Maximize / Minimize code window
+
 
 +
 
 +
====Maximize / Minimize code window====
 
Use the “ Shift + Esc ” shortcut
 
Use the “ Shift + Esc ” shortcut
Useful windows (= Eclipse views)
+
 
Window > Action item
+
====Useful windows====
Window > Output > { Output + Test Results + Search Results }
+
This is like the Eclipse views
Window >Navigating > Navigator
+
 
Window > Other > JavaDoc
+
* Window > Action item
 +
* Window > Output > { Output + Test Results + Search Results }
 +
* Window >Navigating > Navigator
 +
* Window > Other > JavaDoc
 
   
 
   
  
+
 
NetBeans # server configuration
+
===Server configuration===
 
This is not necessary if you installed Glassfish and/or Tomcat with NetBeans.
 
This is not necessary if you installed Glassfish and/or Tomcat with NetBeans.
GlassfishJEE server
+
 
 +
====GlassfishJEE server====
 
Tools > Server > Add a new server
 
Tools > Server > Add a new server
Select Glassfish server
+
 
Choose your server location
+
* Select Glassfish server
netbeans_GF.png
+
* Choose your server location
 +
[[File:Netbeans GF.png|none|Netbeans Glassfish]]
  
 
Let the default settings and click finish
 
Let the default settings and click finish
 
   
 
   
Apache Tomcat servlet container
+
 
Tools > Servers > Add Server…
+
====Apache Tomcat====
Select Apache Tomcat
+
Tools > Servers > Add Server
Choose your location and set a Tomcat user, as defined in $Tomcat/conf/tomcat-users.xml
+
 
netbeans_tomcat7.png
+
* Select Apache Tomcat
 +
* Choose your location and set a Tomcat user, as defined in $Tomcat/conf/tomcat-users.xml
 +
[[File:Netbeans tomcat7.png|none|Netbeans Tomcat]]
  
 
Click finish
 
Click finish
 +
 +
====Other plugins====
 +
Tools > Plugin > Available plugins
 +
* Dark look and feel themes

Latest revision as of 17:16, 10 June 2014


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-8.0-javaee-linux.sh
./netbeans-8.0-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 8 = 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.

Installation step 01

Let the IDE check for update in background.

Installation step 02

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

Look and feel

Tools > Options > Appearance > "look and feel"

The *Nimbus* look is a bit more friendly for your eyes. The gray background is better :)


Fonts & Colors

Tools > Options > "Fonts and colors"

The *Norway Today* theme is a high contrast theme.


Formatter

Remove trailing spaces and unused imports

Tools > Options > Editor > OnSave

  • All languages
    • enable 'remove trailing whitespaces from: 'ALL LINES'
Remove trailing spaces
  • Java
    • Click on the 2 import checkboxes
Adjust import


Code generation

Tools > Options > Editor > Formatting

  • Language: All languages
  • Category: Tabs and indents

none|Margins

  • 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

Code completion


Increase terminal history

Tools > Options > Miscellaneous > Terminal > Increase history to, at least, 80 000

Terminal history


Ant home

If you have your own ANT installation you can use it instead of the default one.

Tools > Java > Ant

ANT configuration


Maven configuration

Plugin configuration

Tools > Options > Java > Maven

  • adjust installation path
  • Adjust JavaDoc and Source retrieval. I advise you to use 1st project only
Maven JavaDoc


Add Maven SkipTests build

Tools > Options > Java > Maven > Edit Global Custom Goal Definitions

  • ADD new "skipTests"
  • Goals: clean install
  • Set Properties: skipTests
Maven 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:

JavaFX config


Plugins

Eclipse code formatter

Tools > Plugins > Available plugins Install "Eclipse code formatter"

Then, after the installation go to: Tools > Options > Java > Eclipse formatter just ENABLE the Eclipse formatter and set a configuration file. Note: don't forget to click format on save at the bottom.

Jacoco code coverage

Tools > Plugins > Available plugins Install:

  • TikiOne JaCoCoverage Plugin
  • TikiOne JaCoCo Reporting Libraries
  • TikiOne JaCoCoverage Libraries
  • JaCoCo Library
JaCoco code Coverage

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
Checkstyle install 01
  • Just fill up the form:
Checkstyle install 02

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 install 03
Checkstyle configuration

Tools > Options > Miscellaneous > Checkstyle

Set your configuration file

Checkstyle usage


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

Tree packages


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
Netbeans Glassfish

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
Netbeans Tomcat

Click finish

Other plugins

Tools > Plugin > Available plugins

  • Dark look and feel themes