This is caused by
- a JAR on the Classpath that contains the package
java.awtthat also exists in the system library but the - JRE System Library is on the Modulepath
In the Java Platform Module System (JPMS) it is not allowed to use the same package in more than one module. If the Modulepath and the Classpath is used, everything on the Classpath is handled as the <unnamed> module (in your case the package java.awt exists in the system module java.desktop and also via the JAR on the Classpath in the module <unnamed>).
Since the JRE System Library cannot be moved from the Modulepath to the Classpath (see this answer by Stephan Herrmann for details), you only have the following options:
- Set the compiler compliance to 1.8 (as you already mentioned)
- Rebuilt the JAR to avoid Java system library package names inside the JAR (if reflection is used, additional code changes may be necessary):
- If you have the source code, change the package names (e.g. change the package and subpackae
javatojava_utilandjavaxtojavax_util) and recreate the JAR - If you have only the
.classfiles you have to decompile the.classfiles first
- If you have the source code, change the package names (e.g. change the package and subpackae