简体   繁体   English

错误:找不到或加载主类ExcelReadWrite

[英]Error: Could not find or load main class ExcelReadWrite

I have a class ExcelReadWrite that runs fine when I run it through eclipse.But when I try to run it from command line I need to set classpath of dependent classes. 我有一个ExcelReadWrite类,当我通过Eclipse运行它时运行良好,但是当我尝试从命令行运行它时,我需要设置依赖类的类路径。

set CLASSPATH=C:\Users\NICSI\.m2\repository\org\apache\poi\poi-ooxml\3.11\poi-ooxml-3.11.jar;C:\Users\NICSI\.m2\repository\org\apache\poi\poi\3.11\poi-3.11.jar;

After setting class path it compiles successfully but when I execute my class then this exception occurs. 设置类路径后,它可以成功编译,但是当我执行我的类时,就会发生此异常。

Error: Could not find or load main class ExcelReadWrite 错误:找不到或加载主类ExcelReadWrite

 public class ExcelReadWrite {

public static void main(String[] args) {
    String inputFile=args[0];
    String outputFile=args[1];
    System.out.println("inputFile 0   "+inputFile);
    System.out.println("outputFile 0   "+outputFile);
    transformExcelFile(inputFile,outputFile);
    //transformExcelFile("E:\\excel\\inputFile.xlsx","E:\\excel\\outputFile.xlsx");
    }
    }

I use following command to compile and execute my class 我使用以下命令来编译和执行我的课程

E:\excelTest>javac ExcelReadWrite.java

E:\excelTest>java ExcelReadWrite
Error: Could not find or load main class ExcelReadWrite

您必须将实际目录添加到您的类路径中:

E:\excelTest>java -cp .;%CLASSPATH% ExcelReadWrite

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM