Java 在 IntelliJ IDEA 中构建并 运行 成功,但在 Mac 终端中编译失败

Java built and run successfully in IntelliJ IDEA but failed to compile in Mac terminal

我在 IntelliJ IDEA 中编写了我的 java 代码,它构建并运行得非常好,但是当我尝试使用 javac 在我的 Mac 终端中编译代码时,我不断收到以下错误:

% javac Main.java 
Main.java:34: error: cannot find symbol
com.business.Helper clsHelper = new com.business.Helper();
            ^       
symbol:   class Helper

location: package com.business

我的 Main 和 Helper 类 都在同一个包中 (com.business),所以我不明白为什么 javac 不能工作。

提前致谢。

通过构建工件(构建 .jar 文件)解决了我的问题,运行 将其用于 运行 我终端中的 .jar 文件: java -cp xxxx.jar xxx.xxx.Main 其中 xxx.xxx 是具有 Main(入口点)的包。