I have a Java program that uses XML parsing so it uses many libraries like:
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
...
import org.w3c.dom.Document;
import org.w3c.dom.Element;
...
It compiles and works when I use Java 1.8. It compiles using command line javac
compiler from OpenJDK 12:
[root@mn ~]# javac --version
javac 12.0.1
[root@mn ~]# alternatives --config javac
...
* 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.fc30.x86_64/bin/javac)
+ 2 java-latest-openjdk.x86_64 (/usr/lib/jvm/java-12-openjdk-12.0.1.12-1.rolling.fc30.x86_64/bin/javac)
But I have some problems when in Eclipse I change "Compiler compliance level" from 1.8 to 11. Then Eclipse shows a lot of errors like:
The package javax.xml.validation is accessible from more than one module: <unnamed>, java.xml
...
Element cannot be resolved to a type
My Eclipse version:
Version: 2019-03 (4.11.0)
Build id: 20190314-1200
EDIT
I updated Eclipse to:
Version: 2019-06 (4.12.0)
Build id: 20190614-1200
The error is the same. At compile time:
The package org.w3c.dom is accessible from more than one module: <unnamed>
At runtime:
Exception in thread "abc" java.lang.Error: Unresolved compilation problems:
The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml
I can compile and run this program using command line JDK12 javac/java.
My question is different from Eclipse Java Editor highlights the error but code compiles because I can see problems in "Problems" tab and I cannot run the program from Eclipse.
What should I do to compile my program in Eclipse using Java11/12?
SOLUTION
I removed xml-apis-1.3.04.jar
from my CLASSPATH
and program compiles and runs from Eclipse. Thank you howlger :-)