I'm using a mac, and I'm trying to run a java project created in Eclipse from the command line. My project folder has a bin and src folder, each of which have folders game and display corresponding to packages. There are .java files in src/*/
and .class files in bin/*/
Here's what worked:
I compiled everything using javac src/*/*.java
. I ran my project by going to the src folder (cd src
) and using java game.Gomoku
following the directions in this answer. Everything worked. The only problem was that now I had a bunch of .class files in my src folder, and I wanted them in my bin folder like Eclipse organized it.
The problem:
I figured out that I could do this with javac -d bin src/*/*.java
. But then when I try java bin/game/Gomoku
or java game/Gomoku
or java -cp bin bin/game/Gomoku
I get the error Error: Could not find or load main class bin.game.Gomoku
. How can I run my project?