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.