I'm using a Java Maven program and I don't know what to enter as the <mainClass>
. I've tried all kinds of things based off of numerous stackoverflow questions, but they are not solving the error.
Each time it says:
Maven Error: Could not find or load main class ...
I have this written inside my pom.xml
(minus the ???
)
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass> ??? </mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
How do I fix these errors?
I got it too, the key was to change the output folder from
bin
totarget\classes
. It seems that in Eclipse, when converting a project to Maven project, this step is not done automatically, but Maven project will not look for main class based onbin
, but will ontarget\classes
.Unless you need the 'maven-assembly-plugin' for reasons other than setting the mainClass, you could use the 'maven-jar-plugin' plugin.
You can see the plugin in practise in the ATLauncher.
The 'mainClass' element should be set to the class that you have the entry point to your program in eg: