Java错误无法找到或加载主类包

Mar*_*n.H 2 java io command-line class package

当我从eclips运行此代码时,它将给出错误打印:

package Chapter08_JavaIOFundamentals;
import java.io.Console;

public class Echo {
     public static void main(String []args) {
          Console console = System.console();
          if(console == null) {
              System.err.println("Cannot retrive console object - are you running your application from an IDE? Exiting the application ... ");
          ystem.exit(-1); }
     console.printf(console.readLine());
     }
 }
Run Code Online (Sandbox Code Playgroud)

但是当我尝试从这样的命令行运行它时.

javac Echo.java //(this will gives no errors)
java Echo
Run Code Online (Sandbox Code Playgroud)

它会给出一个错误:错误:无法找到或加载主类Echo.其他程序就像Hello World一样没问题.这里有什么问题?

Jen*_*ens 5

你必须java -cp . Chapter08_JavaIOFundamentals.Echo从父母的指示中打电话Chapter08_JavaIOFundamentals