Unfitacorn
Unfitacorn

Reputation: 316

Running java program through cmd ERROR: no main method found

I am trying to run a bat file to easily run my program. The Batch file is in the folder project folder, along side the bin folder. I have many classes in many different packages. But the main method is in my Game.class which is located in: bin\xx\xx\xxxx\xxx\xxxxxx\cards\game\Game.class

So I have set two bat files and tried them both: 1.

java -cp bin\xx\xx\xxxx\xxx\xxxxxx\cards\game Game

2.

java -cp bin.xx.xx.xxxx.xxx.xxxxxx.cards.game Game

Both times I get this error:

Could not find or load main class Game

Upvotes: 1

Views: 475

Answers (1)

xerx593
xerx593

Reputation: 13261

This makes more sense:

java -cp /path/to/"class-root"/ full.qualified.name.of.Game

...where "/path/to/class-root/" is probably "bin" in your case, and relates to "default package" (no package). From there on the path should be consistent with the package(s) of your class(es)

Upvotes: 1

Related Questions