18

I get an error Recompile with -Xlint:unchecked for details. in Netbeans. Where can I find the option to uncheck?

wattostudios
  • 8,666
  • 13
  • 43
  • 57
theking963
  • 2,223
  • 7
  • 28
  • 42

2 Answers2

23

You don't "uncheck" that option, you need to add the -Xlint:unchecked parameter to the parameters passed to the Java compiler.

For Ant based projects, this is done through Project Properties -> Build -> Compiling in the "Additional compiler options" input field at the bottom of the dialog (where it says "e.g.: -Xlint:unchecked")

enter image description here

For Maven projects see this answer

  • 1
    Remember to uncheck compile on save to see the warning every time you run file. – GusDeCooL Aug 22 '12 at 07:20
  • 2
    Yeah, the corollary to the comment by @GusDeCooL is that if you want to see these warnings explained just the first time, try a Clean & Build, rather than just Run. They'll show then, but not on any subsequent run. The nasty thing is, you don't even get the warning to turn on -Xlint:unchecked once you've set it. So if you only "Clean & Build" on occasion, that'll be the only time you'll see any of the lint warnings! Caveat Lector (can't say Emptor, cause NetBeans is FOSS)! – likethesky Sep 20 '12 at 23:57
  • Why is this not automatically unchecked? Is there any harm in always leaving it unchecked? – Hunter S Dec 17 '15 at 18:07
  • 6
    For a Netbeans maven project you will need to set the flag in the pom.xml see http://stackoverflow.com/questions/12449251/how-to-compile-using-xlintunchecked-in-a-maven-project – Aner Jul 21 '16 at 20:44
  • 1
    @Aner, +1 for helping with maven projects. Alas, neither the linked page, nor the checked answer links still work. I just get errors from maven saying that the arg is invalid. If I find a solution I will post it back here. – Teto Dec 05 '17 at 07:46
  • @Teto: if you find an answer for Maven, add it to https://stackoverflow.com/q/12449251/330315 not this one. –  Dec 05 '17 at 07:51
  • @a_horse_with_no_name. Thanks, for that suggestion. I have added a comment to the checked solution on that question which adds clarity (I hope). – Teto Dec 05 '17 at 08:00
  • This is not possible in current Netbeans, as of version 12.2. – JN01 Mar 02 '21 at 13:16
  • @JN01: that option is still there. Are you sure you are using an Ant based project? –  Mar 02 '21 at 13:20
  • Oh darn, it doesn't say Ant here. Maven project at hand. Note for anyone stumbling this far: This answer applies to "Java with Ant" project. Not "Java with Maven" and possibly not "Java with Gradle" projects. – JN01 Mar 02 '21 at 13:25
  • 1
    @JN01: see Aner's comment from July 21, 2016 –  Mar 02 '21 at 13:26
0

-Xlint is a JVM parameter. In your project follow this steps:

  1. Project properties
  2. Run
  3. VM Options

And there in the text field you write -Xlint:unchecked

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219