Reputation: 4719
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:
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.
Upvotes: 1
Views: 8387
Reputation: 2167
On IntelliJ, I went to Module Settings then Add Library then Maven, then I entered javax.xml.ws
and added it and voila fixed.
Upvotes: 0
Reputation: 4719
After moving all jars to classpath I got a classNotFoundException for com.sun.xml.internal... upon adding the jar at https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl/2.3.1, everything works.
Upvotes: 1