Tuesday, March 15, 2016

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

When your 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.

From Eclipse Click File > Properties, select Java Build Path and select Libraries Tab.
In the Libraries Tab, select the JRE system library and click Edit, which will pop up a window.

Then click Installed JREs, button, which will pop up a window, which will display the JRE installed, as below.

Now Click Add, and provide the path, where your java jdk have been installed. In the below image, i have configured the path, where my Java JDK has been installed. Once set the path, it will fetch all the JRE libraries under that folder, as shown below.

Once you clicked finish button, the JDK entry will be shown in the Installed JREs window. Now select the newly added path and click apply. Now in the JRE System library window, Click on the Alternate JRE dropdown, it will list the jdk which was added by us, select that and click finish. This will change your JRE System library point to the JDK, what we have installed. Now select the xsd file and generate the JAXB classes, it will generate the classes successfully without any error.

Happy Programming.


  1. thanks man ...none of the other solns were working.

  2. I tried this but no luck :(