I have a simple enough program:
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
public class Main {
public static void main(String[] args) throws JAXBException {
JAXBContext context0 = JAXBContext.newInstance(String.class);
}
}
Because I want to use java-11, javax.xml.bind is no longer provided so I need to add it myself.
I do not want to use maven but add external jars.
As suggested by this https://stackoverflow.com/a/43574427/3014199
I first add jakarta.xml.bind-api-2.3.2.jar
and then its dependency per https://mvnrepository.com/artifact/jakarta.xml.bind/jakarta.xml.bind-api/2.3.2 jakarta.activation-api-1.2.1.jar
to the module path and mark both for export:
Now I get
Error: Unable to initialize main class Main
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
so I add the other library suggested above jaxb-runtime-2.3.2.jar to the classpath:
The error does not change so I add all compile dependencies per https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime/2.3.2:
- FastInfoset-1.2.16.jar
- istack-commons-runtime-3.0.8.jar
- stax-ex-1.8.1.jar
- txw2-2.3.2.jar
to the classpath:
To be sure I again check all jars under "Order and Export", but the error remains.
I have also tried adding all jars to module path and adding all jars to class path but to no avail.