I have a simple Java code:
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Please enter number of the days");
Scanner scanner = new Scanner(System.in);
int days = scanner.nextInt();
System.out.println("The number of seconds in the entered days number is "+days*86400);
}
}
The folder structure is: src\com\company
Inside folder company
, there are Main.java
and Main.class
files.
When I run the app in IDE it runs, when I try to run it on the terminal, I get:
Error: Could not find or load main class Main.class Caused by: java.lang.ClassNotFoundException: Main.class
The execution of commands in any of the following ways
- From inside
company
folder:
java Main.class
- From inside
src
folder:
java com.company.Main.class
java.com.company.Main
give the same error.
What is wrong here?