且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 java Main 调用另一个 java 文件中的方法

更新时间:2023-12-04 14:41:22

您是否尝试过更改包装名称?正如 user 所提到的,包名不能以数字开头.尝试 com.MyJava,而不是 com.MyJava.002mavern,代码将编译并运行.

Have you tried changing the packing name? As user mentioned, package name cannot start with a number. Try com.MyJava, instead of com.MyJava.002mavern, and the code will compile and run.

更新 #2:除了错误的包,似乎并不是所有的 Java 文件都被编译.尝试 javac *.java 来编译两个 Java 文件.此外,有关 javacjava 命令的更多信息,请参阅以下 2 个 Java 8 参考:

UPDATE #2: Besides the incorrect package, it seems not all the Java files are compiled. Try javac *.java to compile both Java files. Also, see these 2 Java 8 references for more information on the javac and java commands: