Apache NetBeans version
Apache NetBeans 31 latest release candidate
What happened
At Tools > Editor > OnSave > Java
- Uncheck
Remove unused Imports
- Check
Organize Imports
- Apply
- Save the following (note ArrayList is commented out)
Observe
import java.util.ArrayList; is removed even though Remove Unused Imports is unchecked.
package com.raelity.play;
import java.util.ArrayList;
import java.util.LinkedList;
public class DontRemoveUnusedImportOnSave
{
// ArrayList<Object> l1;
LinkedList<Object> l2;
}
Language / Project Type / NetBeans Component
java/OnSave (hints?/options?)
How to reproduce
See OP.
If this behavior is what's wanted (it's not what I want), then in the UI when Organize Imports is checked, Remove Unused Imports should be both checked and disabled automatically.
Did this work correctly in an earlier version?
No / Don't know
Operating System
Linux harmony 7.0.9-76070009-generic #202605191504177946462222.04~ef31795 SMP PREEMPT_DYNAMIC Fri M x86_64 x86_64 x86_64 GNU/Linux
JDK
openjdk 26 2026-03-17 OpenJDK Runtime Environment (build 26+35-2893) OpenJDK 64-Bit Server VM (build 26+35-2893, mixed mode, sharing)
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
No response
Are you willing to submit a pull request?
No
Apache NetBeans version
Apache NetBeans 31 latest release candidate
What happened
At
Tools > Editor > OnSave > JavaRemove unused ImportsOrganize ImportsObserve
import java.util.ArrayList;is removed even thoughRemove Unused Importsis unchecked.Language / Project Type / NetBeans Component
java/OnSave (hints?/options?)
How to reproduce
See OP.
If this behavior is what's wanted (it's not what I want), then in the UI when
Organize Importsis checked,Remove Unused Importsshould be both checked and disabled automatically.Did this work correctly in an earlier version?
No / Don't know
Operating System
Linux harmony 7.0.9-76070009-generic #202605191504
177946462222.04~ef31795 SMP PREEMPT_DYNAMIC Fri M x86_64 x86_64 x86_64 GNU/LinuxJDK
openjdk 26 2026-03-17 OpenJDK Runtime Environment (build 26+35-2893) OpenJDK 64-Bit Server VM (build 26+35-2893, mixed mode, sharing)
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
No response
Are you willing to submit a pull request?
No