Based on java documentation, I've set up my project as such:
Source files are in C:\...\sources\com\myname\tictactoe\
And my class files are in C:\...\classes\com\myname\tictactoe\
When I try to run a class (Main.java
) in that directory (on powershell) by running "java Main
", I get "Error: Could not find or load main class Main Caused by: java.lang.ClassNotFoundException: Main
". All my files start with "package com.myname.tictactoe;
", and from what I understand that's how they're supposed to be. What am I doing wrong?
CodePudding user response:
Your java class has a package name so you will not be able to run just java Main. You will need to run java com.myname.tictactoe.Main.
CodePudding user response:
Change directory to C:\...\classes
then run
java -cp . com/myname/tictactoe/Main