In a Java project running in VSCODE, when executing a certain class, there is a conflict between the rt.jar library (from the JDK itself); and the referenced library jaxb-api-osgi.jar. Specifically, it loads the javax.xml.bind.JAXBContext class from the rt.jar; instead of the one included in jaxb-api-osgi.jar.
That is, I would like the referenced library jaxb-api-osgi.jar to have precedence over the rt.jar
This configuration in settings.json doesn`t helps:
{
"java.project.referencedLibraries": [
"lib/**/*.jar",
"c:\PROYECTOS\Librerias\glassfish4\jaxb-api-osgi.jar"
],
"java.jdt.ls.java.home": "C:\Instalados\Java\jdk8u192-b12"
}
2
Answers
The contribution is very interesting. I have learned a lot from it.
But, it hasn't worked for me.
However, I put the details of the changes here because I'm sure it will help someone.
I finally got everything working for me from a clean workspace using Maven projects.
(I give the answer as good because of the detail of it, and because surely I was missing something to do correctly).
settings.json:
launch.json:
Add
exclude
to excludert.jar
library underjava.project.referencedLibraries
configuration.Example settings.json
Add the following configuration to
vmArgs
in launch.json to add thejaxb-api-osgi.jar
library to the boot classpath of the JVM with a higher priority than the default boot classpath (which includesrt.jar
)Note: The launch.json file will only be referenced by using
Starting Debugging
orRun Without Debugging
or executing the file in the Run and Debugging panel.