-9

我正在尝试从命令提示符运行 java 项目。但是当我输入

javac BatchImport.java

然后我得到了错误。这是这些错误的屏幕截图

编译错误

这是日志

D:\LS360BatchImportIntegration\src\main\java\com\softech\ls360\integration>dir

08/05/2013  05:47 AM    <DIR>          .
08/05/2013  05:47 AM    <DIR>          ..
08/01/2013  05:03 AM            11,707 AbstractBatchImport.java
08/05/2013  04:06 AM             1,591 BatchImport.java
08/05/2013  05:47 AM    <DIR>          email
08/05/2013  05:47 AM    <DIR>          file
08/05/2013  05:47 AM    <DIR>          ftp
08/05/2013  05:47 AM    <DIR>          sftp
08/05/2013  05:47 AM    <DIR>          util
08/05/2013  05:47 AM    <DIR>          vintners
08/05/2013  05:47 AM    <DIR>          webservice
           2 File(s)         13,298 bytes
           9 Dir(s)  122,904,571,904 bytes free

D:\LS360BatchImportIntegration\src\main\java\com\softech\ls360\integration>javac BatchImport.java
BatchImport.java:12: package com.softech.ls360.integration.util does not exist
import com.softech.ls360.integration.util.IntegrationUtil;
                                     ^
BatchImport.java:13: package com.softech.ls360.integration.util does not exist
import com.softech.ls360.integration.util.VU360IntegrationProperties;
                                     ^
BatchImport.java:14: package com.softech.ls360.integration.vintners does not exist
import com.softech.ls360.integration.vintners.Vintners;
                                         ^
BatchImport.java:46: cannot find symbol
symbol  : class Vintners
location: class com.softech.ls360.integration.BatchImport
            Vintners vintners = new Vintners(customerName, randomUUIDString);
            ^
BatchImport.java:46: cannot find symbol
symbol  : class Vintners
location: class com.softech.ls360.integration.BatchImport
            Vintners vintners = new Vintners(customerName, randomUUIDString);
                                    ^
5 errors

D:\LS360BatchImportIntegration\src\main\java\com\softech\ls360\integration>

我的主要课程也包括其他课程。其他类也包括其他类。如何编译包含多个类的项目?

谢谢

4

3 回答 3

4

javac assumes the current directory is the location of the default package. You are running it from deep inside the source directory structure.

cd back out to src/main/java directory and use the full path to the file you want to compile.

于 2013-08-05T13:22:20.060 回答
0

假设LS360BatchImportIntegration是您项目的base_directorycdbase_directory。从那里使用以下命令:

javac -d classes src\main\java\com\softech\ls360\integration\BatchImport.java

这将编译您的类并将它们放在base_directory\classes文件夹中。如果您的项目具有外部依赖项,请在命令中使用-cp选项javac

于 2013-08-05T15:07:30.387 回答
0

错误日志:

BatchImport.java:12: package com.softech.ls360.integration.util does not exist
import com.softech.ls360.integration.util.IntegrationUtil;

表示com.softech.ls360.integration.util.IntegrationUtil;在构建路径上找不到该类。因此,您需要将 jars 添加到包含上述类的构建路径中。

我建议您使用 IDE 来运行该类,并在其构建路径中包含所有类。此外,如果您想通过命令提示符完成它,这个SO 答案应该可以帮助您。但我坚持你使用 IDE。

于 2013-08-05T13:39:30.947 回答