Error: Could not find or load main class com.google.gwt.dev.Compiler while compiling a GWT project
Solution 1
Try Run As > Run Configurations
, delete the current configuration by clicking on the X top left. Apply and close. Now, Run As > Web application
. A default configuration will be created.
If you have any VM arguments, copy them before doing the steps above.
Solution 2
Check things as mentioned in below snapshots:
check whether Main class
is having value com.google.gwt.dev.DevMode
or not.
Go To Run Configuration >
Go To Project Properties > Build Path
Check whether GWT SDK is installed properly or not
Solution 3
set the "classpath" environment variable = %gwt_installed_dir%
Solution 4
I came across this problem on an old GWT project that was using GWT version 2.4.0 rather than the current 2.8.2. I think older versions of GWT run with legacy/classic development mode. They run the main class in com.google.gwt.dev.DevMode found in gwt-dev.jar.
The error is actually what it says it is. DevMode exists in gwt-dev.jar. You’re missing gwt-dev.jar somewhere in your classpath. You either need to add it as a maven dependency in your pom.xml and then update your maven dependencies like so:
- In pom.xml:
<properties>
<!-- this should be whatever version you are using -->
<gwt.version>2.4.0</gwt.version>
</properties>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwt.version}</version>
</dependency>
- Update dependencies.
In Eclipse, right click project → maven → “update project...” → tick ‘force update of snapshot/releases’ (just cause you want to be thorough. It’s probably not necessary in this case though). → press OK button.
OR check that you have gwt-dev.jar somewhere in your classpath:
- In Eclipse, right click project → build path → configure build path → libraries tab → make sure you either have the GWT SDK added as a library, or that gwt-dev.jar exists somewhere in your maven dependencies.
Solution 5
I would recommend creating maven or ant scripts to build outside eclipse.
This way other developers in your team, that maybe don't use eclipse can also build/run the application.
Related videos on Youtube
Mayur Jadhav
Updated on June 21, 2022Comments
-
Mayur Jadhav almost 2 years
Whenever I try to compile any of my GWT application the compilation fails with the error message "Error: Could not find or load main class com.google.gwt.dev.Compiler". This problem started after I made some changes to the path and classpath environment variables while installing Tomcat, I don't know whether these changes caused the problem. I tried to reinstall GWT plugin but all in vain. Any help would be greatly appreciated. I am using Eclipse 4.3 and GWT SDK 2.6.0.
-
Mayur Jadhav about 10 yearsThanks. That did the trick. But I didn't understand how the old web app configurations got deleted.
-
Mayur Jadhav about 10 yearsThanks. I had to create new launch configurations somehow the old ones got deleted.
-
Braj about 10 yearsIt will start working after putting value of
Main Class
as shown in above snapshots.