-1

I'm completely new to programming and I just built a Maven project with very poorly structured packages. Now, when I try to run my project from the terminal with the command "mvn compile exec:java -Dexec.mainClass=main.java.main.TakBoard", it won't run. The error message is:

[ERROR] Could not find goal 'java-Dexec.mainClass=main.java.takgame.main.TakBoard' in plugin org.codehaus.mojo:exec-maven-plugin:1.6.0 among available goals exec, help, java -> [Help 1]

My github project link is here, so you can see the structure. Main class is in TakGame/src/java/main/takgame/main/TakBoard.java

I also tried to remove the last main class once and built the project again in NetBeans. Didn't work, so I added the main class again. How can I make this work without having the do the whole project all over again?

azro
  • 53,056
  • 7
  • 34
  • 70
  • Structure should be `src/main/java` not src/java/main. – Roddy of the Frozen Peas Nov 19 '19 at 20:01
  • While links to external resources are fine to add context and clarity to your question, you need to include enough of your code **in the question itself** to make it answerable. Links can break, and people may be blocked from accessing them. – azurefrog Nov 19 '19 at 20:01
  • Possible duplicate of [How I run maven project in cmd line](https://stackoverflow.com/questions/33977187/how-i-run-maven-project-in-cmd-line) – Supun Kavinda Nov 19 '19 at 21:13

1 Answers1

0

To run a java application, you need to provide the fully qualified name of the class that implements a main method. The fully qualified name consists of the package that the file exists in (which is the same as the diretory structure) and the class name.

With this

... -Dexec.mainClass=main.java.main.TakBoard

You're not using the package that you used for the class. I'm not really sure what you're using.

The package TakBoard is in is takgame.main. This means that the fully qualified name of the class is takgame.main.TakBoard. That's what you need to pass to the exec plugin's property.

... -Dexec.mainClass=main.java.main.TakBoard

As a side note - I'd suggest dropping maven. Instead, do all of the compiling and classpath management by hand on the command line (at least for a while). It's way more work. But you'll understand the classpath and package structures better for it.

Jason Warner
  • 2,469
  • 1
  • 11
  • 15