How to compile on save?

血红的双手。 提交于 2019-12-20 01:40:26

问题


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?


回答1:


Change your netbeans project's project.properties like below.

  1. Find below line in project.properties file

    compile.on.save.unsupported.javafx=true

  2. Change this value to set to false

    compile.on.save.unsupported.javafx=false

  3. After change this file, compile on save option will be enabled and you are good to go.




回答2:


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>

Also...

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)




回答3:


You should choose the Sources rather than Build from the Categories.



来源:https://stackoverflow.com/questions/17103371/how-to-compile-on-save

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!