Hi, in general: the runtime JDK does not influence the JDK range projects can use. It also doesn't really matter what JDK version was used to build NB, as long its JDK 17 or later.
NetBeans 26 supports running on JDK 24, 21 and 17 and projects up to --release 24. If you are using JDK 25 API it should be fine, but JDK 25 specific language features might not work (editor will likely show errors or request to set --enable-preview even though something is no longer in preview). For JDK 25 support you would have to wait for NB 27 nightly builds, once nb-javac based on JDK 25 is integrated. The code you posted doesn't seem to use any java 25 language feature, so you could simply pass --enable-preview --release 25 and it should work fine using NB 26. -mbien On 6/4/25 22:40, Kenneth Fogel wrote: > As a Canadian I must begin by apologizing for what there may be an obvious > solution. > > I am puzzled by the behaviour of NB when working with Java 25. I installed NB > 26 with its version of Java. I created a project that required Java 25 and > configured NB, in netbeans.conf, to use the Java 25 EA. I also verified that > the project properties referenced JDK-25. The NB editor does not show any > errors or warnings. The program runs flawlessly from the CLI. Here is the > code: > > void main() { > var secretNumber1 = new Random().nextInt(10) + 1; > int guessNumber; > do { > guessNumber = Integer.parseInt(IO.readln("Guess a number from 1 to > 10: ")); > if (guessNumber < secretNumber1) IO.println("Too small"); > else if(guessNumber > secretNumber1) IO.println("Too large"); > } while (secretNumber1 != guessNumber); > IO.println("You win!"); > } > > But when I run it in NB I get: > > Error: LinkageError occurred while loading main class JavaSpaghetti > java.lang.UnsupportedClassVersionError: JavaSpaghetti (class > file version 68.65535) was compiled with preview features that are > unsupported. This version of the Java Runtime only recognizes preview > features for class file version 69.65535 > > The features I am using are no longer preview and so -enable-preview is not > required. Even if I leave it, the code does not run. > > Am I to assume that the only way to make this work on Java 25 is to compile > the NB source using Java 25? > > No, that is not it because when I just compiled from source with Java 25 the > results were the same. Somewhere it is blocking Java 25. Ant reports that the > java.class.version is 69 which is to be expected using Java 25. Also, if I > run a program that does not use any JEP 512: Compact Source Files and > Instance Main Methods then it runs fine. > > What else might I be missing? > > Ken > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org For additional commands, e-mail: dev-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists