I'm following a tutorial on beginning java and trying to run the following:
package Examples;
public class Squares {
public static void main(String[] args) {
// Use a Scanner to read from standard in
java.util.Scanner scanner = new java.util.Scanner(System.in);
int num = 0;
System.out.print("Please enter a number: ");
num = scanner.nextInt();
scanner.close();
}
}
I'm able to compile it in a folder within a folder on my desktop (learn-java1/ch03/Examples) and create a Squares.class file within the same folder.
But when I try to run it, I get the error: "Could not find or load main class"
I've tried running the following with no success:
java Squares
java -cp . Squares
Any help would be appreciated, thanks!