How can I enable Compile on Save in Apache Netbeans IDE 11.0?
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.
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:
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:
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
The nbjavac plugin needs to be installed. See also here.
Related
I have downloaded Java code from GitHub and am trying to configure or build my changes into a Java package. But I'm getting the below error. I'm not sure what version of Java I need to use to build this project. Any pointers or suggestions would be really helpful.
error: cannot access Copier
import com.example.records.core.Copier;
^
bad class file: /home/user957/.gradle/caches/modules-2/files-2.1/com.example.streaming/streaming-core/v1.36.1/758f1477d776e3273c5397d2d5d7e19b5fa46326/streaming-core-v1.36.1-sdk.jar(/com/example/records/core/Copier.class)
class file has wrong version 62.0, should be 57.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
mySystem JDK version
java -version
openjdk version "18.0.2.1" 2022-08-18
OpenJDK Runtime Environment Temurin-18.0.2.1+1 (build 18.0.2.1+1)
OpenJDK 64-Bit Server VM Temurin-18.0.2.1+1 (build 18.0.2.1+1, mixed mode, sharing)
Try JDK version 1.9 or higher.
If class files has version 62.0,then least JDK 9 installed on system to be able to compile them
I solved this problem, by just reinstalling my JDK. If you're using IntelliJ, just head to the project settings and click download in the JDK dropdown menu.
I also solved this problem on my Ubuntu 20.04 machine by running sudo apt install openjdk-13-jdk, which installs the jdk and
sudo update-alternatives --config java, which updates the index of the newest jdk (i think).
If I understood you wrongly with the version needed, just adjust the number behind openjdk- to whatever version you need.
All versions to their corresponding class file versions
So I recently installed OpenJDK 17 for Linux and it came to me as a tar.gz file. I installed it after clicking a link I got on vs code after installing a java extension pack (I had Java 11 installed by default, but I decided to get the latest version), under the adoptium's temurin tab of installing Java from vsc. So after doing so I reloaded the screen, but still no change. Vs code is still not detecting java 17 or 11 is installed. Also when I type java --version in the terminal, I get :
OpenJDK 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
How do I make Java 17 the default version for VSC?
You've added jDK11 to PATH, discard this configuration then add jdk17 to PATH.
Then turn to VS Code, open User Settings.json and add
"java.home": "<path to jdk17>",
Then reload window to make this change effective.
I did the following steps to fix the issue(I use Debian based Linux OS):
Went to my software manager, searched for JDK 11.
Deleted JDK 11 and installed JDK 17 from the software manager
Went to VSC and installed an extension "java run".
Ran the code and it worked just fine.
I get the following message after exiting out of NetBeans and then re-starting.
Warning - could not install some modules: JavaFX wrapper - No module providing the capability org.openide.modules.jre.JavaFX could be found. Another module could not be installed due to the above problems.
I am using Java 15, with JavaFX. I didn't have the issue with 12.3 and Java 15, but now I get it at least once a day, depending on how often I leave and re-enter.
I have a work-around. I replace the NetBeans cache with a clean copy kept for this purpose, and I can then restart and continue working without the error, but this is a bit tedious after the first couple of times, each day.
Product Version: Apache NetBeans IDE 12.4
Java: 15.0.4; OpenJDK 64-Bit Server VM 15.0.4+5-MTS
Runtime: OpenJDK Runtime Environment 15.0.4+5-MTS
System: Windows 10 version 10.0 running on amd64; UTF8; en_AU (nb)
I have found the solution, I have re-installed, and skipped the installation of the nb-javac plugin. I had forgotten that I did this on my older installations, until I re-read the post below. Everything is fine now.
NetBeans plugin fails if nb-javac installed
What's "nb-javac" in Apache NetBeans?
NetBeans project collapses tree menu, but this did not occur earlier.
Product Version: NetBeans IDE 7.4 (Build 201310111528)
NetBeans IDE NetBeans 7.4 Patch 2
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Windows 7 version 6.1 running on amd64; Cp1251; ru_RU (nb)
Usually for that kind of issues there is no solution. Try to report the bug to the netbeans community if it is not already reported. If you want to have a clear solution to your problem change you netbeans to an earliest version or reinstall this particular version.
PS: You should update you Java version to the latest one (1.7.0_51).
there may be some issues with the istallation processes try
1) reinstaiing
2) changing perspective mode
3) refeshing project
The problem may be with your Netbeans compatibility, because you are using 64 bit system. Your Netbeans is might be compatible with 32 bit system only. Or other possible thing is that Netbeans is not installed properly.
So to solve this problem you can do this:
Reinstall Netbeans
Search for 64 bit compatible Netbeans version, Download it, and then install it properly.
Delete your existing project and create a new project.
I was using the NetBeans IDE 7.3, however on open an existing mobility project I get lots of red dots,
on rolling over the dot near the package statement it says
'cannot access java.lang"
Fatal Error:" Unable to find package java.lang in classpath or bootclasspath"
while the other red dots below near other class or Identifier statements say
"cannot find symbol."
I have JDK 1.7.0_11 installed.
I tried the following to correct the errors:
1. Reinstalled JDK 1.7 .
2. Reinstalled NetBeans 7.3.
3. Uninstalled NetBeans 7.3 and installed NetBeans 7.3
However nothing worked.
Product Version: NetBeans IDE 7.3 (Build 201302132200)
Updates: Updates available
Java: 1.7.0_11; Java HotSpot(TM) Client VM 23.6-b04
Runtime: Java(TM) SE Runtime Environment 1.7.0_11-b21
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)
User directory: C:\Users\SSNEHAL\AppData\Roaming\NetBeans\7.3
Cache directory: C:\Users\SSNEHAL\AppData\Local\NetBeans\Cache\7.3
I also searched google but could not find any valid answers.
What should I do?
Interestingly I get these errors only on Mobility projects and that too on opening an existing Mobility project,
New Mobility and J2SE projects dont give me any errors.
If new projects work, Netbeans probably lost the platform configuration for your project (this happened to me once). To reconfigure it go to Project Properties -> Platform and set the Platform Type and Emulator to your JavaME platform.