I want to set main class in pom.xml to run exec:java I checked lots of resources but still have the same error.
I tried putting it in under execution tag.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.mertilovski.app.Game</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
My main class in under app directory.
TicTacToe/TicTacToe-Game/src/main/java/com/mertilovski/app
pom.xml is in TicTacToe directory. That is where I run
mvn exec:java -Dexec.mainClass="com.mertilovski.app.Game"
I tried making an package com.mertilovski.app; declaration on top.
mvn exec:java -Dexec.mainClass="src.main.java.com.mertilovski.app.com.mertilovski.app.Game "
Result is :
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------
------------
[INFO] Building TicTacToe-Game 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------
------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) > validate @
TicTacToe-Game >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) < validate @
TicTacToe-Game <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ TicTacToe-
Game ---
[WARNING]
java.lang.ClassNotFoundException: com.mertilovski.app.Game
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:748)
[INFO] ------------------------------------------------------------
------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------
------------
[INFO] Total time: 0.639 s
[INFO] Finished at: 2019-03-26T01:30:18+03:00
[INFO] Final Memory: 8M/106M
[INFO] ------------------------------------------------------------
------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-
plugin:1.2.1:java (default-cli) on project TicTacToe-Game: An
exception occured while executing the Java class.
com.mertilovski.app.Game -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven
with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug
logging.
[ERROR]
[ERROR] For more information about the errors and possible
solutions, please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException