'How to fix "Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass?

I've started a project using java 16 and I'm getting errors in the project all over the place:

An error has occurred. See error log for more details.
Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @6dfcffb5

It looks like the code I have from different version of java is not working in this particular version. Any idea what I need to change maybe in the pojo class. I have only 1 pojo in the application cause it is micro service.

Thanks.



Solution 1:[1]

You can just define the JRE system library by precising the path following the next steps: Project Folder -> Properties -> Java build path -> double clicks on JRE system library and choose your installed JRE, it works for me. And sorry for my bad English

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 Youness Hourri