Eclipse uses ECJ (Eclipse Compiler for Java) for building liferay plugins. ecj.jar needs to be configured in eclipse to avoid ecj error.
Eclipse is one of the most well know IDE for Java professional today. Liferay provides eclipse plugin to build and run various liferay plugins( like portlets, hooks, layouts, themes, ext etc) on server. Eclipse uses separate compiler called ECJ (Eclipse compiler for java) to build liferay plugins.
Liferay eclipse plugin uses this compiler (ECJ) to build plugins which is most of the time faster than javac. Liferay plugin SDK ships with ecj.jar. When you configured eclipse plugin for liferay sdk and server, you might encounter following ecj error while building any potlet (or any other liferay plugins like hook, theme, layout etc).
Task cannot continue because ECJ is not installed.
ECJ was automatically installed. Please rerun your task.
It instruct ant to use ecj to build liferay plugin and above ecj error is encountered because eclipse doesn’t fine ecj jar.
Resolve ECJ error in clipse
To avoid this follow below steps.
Click on Window–>Preferences menu from eclipse and select Ant–>Runtime as per below screenshot.
- Click on ‘Ant Home Entries(Default)‘ and click on ‘Add External Jars‘.
- Celect ecj.jar from your liferay-plugi-sdk/lib folder as per below screenshot.
- Click on ‘Open’ button and select ‘OK’ button from eclipse preferences window.
And you are done. You can verify by building any portlets (or any other liferay plugins) to make sure the ECJ error will not appear again.
Another way to configure ecj.jar in clipse.
As an alternative way, you can place ecj.jar from your folder to your eclipse/plugins/org.apache.ant_1.8.3.v201301120609/lib folder. If you observe this path (eclipse/plugins/org.apache.ant_1.8.3.v201301120609/lib) after performing the first option, you will see the ecj.jar is added in this place. This ant version under eclipse/plugins may be different based on your eclipse version.
Note: This issue (ecj error) is only occur (until you point ecj.jar into eclipse ant) while building liferay plugins from eclipse. If you run ant script through command prompt, you won’t encounter such issue.
- Liferay provides eclipse plugin to build and run various liferay plugins on Liferay server.
- Eclipse use’s separate compiler called ECJ (Eclipse Compiler for Java) to compiler liferay plugins.
- Liferay plugins sdk ships with ecj.jar which needs to be configure in eclipse otherwise it will throw ecj error while building liferay plugins.
- You can either directly place it from your liferay-plugin-sdk/lib folder to your eclipse/plugins/org.apache.ant_XXXX/lib folder.
- You can refer this link to get more info about ECJ error.