Reputation: 2022
I would like to compile the project every time I save, but in properties this option is greyed, so for any change I do I have to click save then clean and build.
How can I do to avoid to clean and build for every code modification?
Upvotes: 3
Views: 14759
Reputation: 6469
Answer for Apache NetBeans 9, 10, 11 using Maven.
Configuration is set at nbactions.xml
file, usually it'll look similar to this:
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>war</packaging>
<packaging>ear</packaging>
<packaging>ejb</packaging>
</packagings>
<goals>
<goal>package</goal>
</goals>
</action>
</actions>
To activate the Compile On Save
option you only need to add the <netbeans.compile.on.save>
setted to all
, it'll look like this:
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>war</packaging>
<packaging>ear</packaging>
<packaging>ejb</packaging>
</packagings>
<goals>
<goal>package</goal>
</goals>
<properties>
<netbeans.compile.on.save>all</netbeans.compile.on.save>
</properties>
</action>
</actions>
At latest NB 10 and 11 you may see the warning It is recommended to install nb-javac Library to improve Java editing experience and enable compile on save
at Notifications
section:
You just need to install that plug-in (nb-javac) by clicking on that link, more info here, there's currently an open issue for NB11.2, if you have problems with it try using beta 3 (or latest)
Upvotes: 3
Reputation: 1961
Change your netbeans project's project.properties like below.
Find below line in project.properties file
compile.on.save.unsupported.javafx=true
Change this value to set to false
compile.on.save.unsupported.javafx=false
After change this file, compile on save option will be enabled and you are good to go.
Upvotes: 3
Reputation: 181
You should choose the Sources rather than Build from the Categories.
Upvotes: 1