'Netbeans 12.5 imported older project cannot be loaded - Unsupported class fle major version 61

Netbeans 12.5 - It worked in Netbeans 11
When I open the project I get this error

enter image description here

When I tell Netbeans that I want to resolve it it doesn't work and I get this warning.
enter image description here

  • Could not run build action using connection to Gradle installation 'C:\Users\ff.gradle wrap per\dists\gradle-7.0-bin\2p9eb qfab irfozi6 760gco7n\gradle~

  • Could not open cp_int generic class cache for intialzation script "c:\Program Files\NetBeans-12.5\netbeans\extide\modules\gradle\nb-toolng.gradie’ (C:\Users\ffi.gradie\caches\7.0\scripts\dtnvzzibbagvwi42m3qn4ji).

  • Could not open cp_int generic class cache for intialzation script ‘c:\Program Files\NetBeans-12.5\netbeans\extide\modules\gradle\nb-tooing.gradie’ (C:\Users\ffi.gradle\caches\7.0\scripts\dtnvzzibbagvwi42m3qn4ji).

  • BUG! exception in phase 'semantic analysis'in source unit‘ BuidScript_' Unsupported class fle major version 61

  • Unsupported class fie major version 61

I tried changing the gradle version in Tools->Options->Java->Gradle to 6 doesn't seem to change anything because the warning still mentions gradle 7. I tried changing the java version but that doesn't seem to work either.

enter image description here

I tried deleting the cache both in the project and in the gradle folder C:\Users\<user>\.gradle



Solution 1:[1]

Unsupported class file major version 61

It says that JDK 17 is unsupported. Your Gradle is running on JDK 17. Two solutions for your problem:

1. Use JDK 16 or lower

Go to your gradle.properties file, and change (or add, if it doesn't exist) org.gradle.java.home to point towards JDK 16 like this:

org.gradle.java.home = path/to/JDK/16

Don't add quotation marks to the path

2. Use Gradle 7.3.3

Gradle 7.3.3 has support for JDK 17. Go to your gradle\wrapper\gradle-wrapper.properties file and change distributionUrl to

distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JustinW