Showing posts with label JAXB. Show all posts
Showing posts with label JAXB. Show all posts

Saturday 18 February 2017

Eclipse error: Could not find or load main class com.sun.tools.internal.xjc.XJCFacade

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"

Could not find or load main class com.sun.tools.internal.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.

Could not find or load main class com.sun.tools.internal.xjc.XJCFacade 

Could not find or load main class com.sun.tools.internal.xjc.XJCFacade

Select JDK installation directory and click on Finish.

Could not find or load main class com.sun.tools.internal.xjc.XJCFacade

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.

Could not find or load main class com.sun.tools.internal.xjc.XJCFacade

Now select the xsd file and generate the JAXB classes, it will generate the classes successfully without any error.