Could not find or load main class com.sun.tools.internal.xjc.XJCFacade
Problem: When I right click a schema file and choose "Generate" and "JAXB Classes", I see the following stack trace in then console:
"java.lang.NoClassDefFoundError: com/sun/tools/xjc/XJCFacade
Caused by: java.lang.ClassNotFoundException: com.sun.tools.xjc.XJCFacade"
Solution: When eclipse project libraries are not pointing to JDK, and instead it is pointing to the JRE, you will get this error "Error: Could not find or load main class com.sun.tools.internal.xjc.XJCFacade". If the JDK path was not configured in your installed JRE's please do the following.
Go to Window -> Preferences, Select Installed JREs. Click on Add and select Standard VM and click Next.
Select JDK installation directory and click on Finish.
Once you clicked finish button, the JDK entry will be shown in the Installed JREs window. Now select the newly added path and click OK. Eclipse will build all your project.
Now select the xsd file and generate the JAXB classes, it will generate the classes successfully without any error.
Thanks for the post, But I am facing the same issue after the JDK Added.
ReplyDeleteMe too
Deleteme too
Deleteme too
ReplyDeleteme too
ReplyDeletejava.xml.bind was deprecated in 9
ReplyDeletei changed jre to jdk, Still problems away
ReplyDeleteThanks!
ReplyDeleteTo those who still getting error, check in the "Console" tab, because maybe you are still using the old jre instead of the "jdk1.8.0_111\bin\javaw.exe".
This helped me:
ReplyDeleteWindow -> Preferences -> Java -> Installed JREs -> Ececution Environments -> JavaSe-1.8 -> Check the jdk box
Hope it helps
Worked for me! Thanks
DeleteWorked also for me! Thanks!
DeleteThat's great!! Thanks
DeleteThis solution help me
ReplyDeleteworks for me. thanks
ReplyDeleteThanks. Additionally, I had to remove the current project runtime that was a JRE and replace it with the JDK.
ReplyDeleteabove solution helped
ReplyDeleteThank you. After changing to JDK it worked for me.
ReplyDelete