Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable Compile on Save option in Netbeans 11

How can I enable Compile on Save in Apache Netbeans IDE 11.0?

https://i.stack.imgur.com/OOYQE.png

Output of my java -version

java version "11.0.4" 2019-07-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.4+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.4+10-LTS, mixed mode)

I tried setting:

  • compile.on.save=true in nbproject/private/private.properties

  • compile.on.save=true in nbproject/private.properties

  • compile.on.save.unsupported.javafx=true in nbproject/private.properties

  • compile.on.save.unsupported.javafx=false in nbproject/private.properties

and possible combinations of these. But not to succeed so far.

like image 651
sazzad Avatar asked Mar 04 '23 06:03

sazzad


2 Answers

TLDR:

  • You need to install the nb-javac library to enable compile on save.
  • However, due to a NetBeans bug, you must use version 11.2 beta 3 of NetBeans for that to work.

You may be seeing this issue because you need to install the nb-javac library. To determine whether installation is necessary:

  • Open the Notifications window by selecting Window > IDE Tools > Notifications.
  • If installation is required there will be a message stating "Install nb-javac Library" in the Notifications window:

    nb-javac library

To install the nb-javac library:

  • Unfortunately you must use version 11.2 beta 3 (or later) of NetBeans. This is due to an unrelated problem with the installation of nb-javac.
  • You can download NetBeans 11.2 beta 3 from this page. The file is named netbeans-11.2-beta3-bin.zip. Just download the zip file, then unzip it in a new directory.
  • From version 11.2 beta 3 of NetBeans (or later), select the notification in the Notifications window.
  • Click the link in the right pane with the text "It is recommended to install nb-javac Library to improve Java editing experience and enable compile on save".
  • A wizard for installing the library will be shown:

    Wizard

  • Complete the steps in the wizard. Once installation is complete, restart NetBeans.

After restarting NetBeans you should find that:

  • The nb-javac library has been installed.
  • The Compile on Save checkbox for your project is enabled.

I could reproduce your problem in NetBeans 11.1, and I have verified that this solution worked for me.

Notes:

  • See Bug Report NETBEANS-2552 Fail to install nb-javac Library on NetBeans 11 for details on why you need to upgrade NetBeans to version 11.2 beta 3 to fix this issue.
  • If you prefer not to use a beta release, version 11.2 of NetBeans should be available very soon.
  • See these articles for further information on nb-javac:
    • "What's "nb-javac" in Apache NetBeans?".
    • Overview: nb-javac
like image 71
skomisa Avatar answered Mar 08 '23 10:03

skomisa


The nbjavac plugin needs to be installed. See also here.

like image 35
Joachim Rohde Avatar answered Mar 08 '23 12:03

Joachim Rohde