错误:使用外部jar文件和cmd时找不到或加载主类Main

时间:2018-07-19 04:37:33

标签: java cmd jar apache-poi javac

我在项目中包含了两个jar文件。我正在使用cmd而不使用任何IDE。 该项目正在成功编译。 但是,当我尝试运行程序时,出现以下错误: “找不到或加载主类Main”

我用于编译的命令:

  

javac -classpath poi-ooxml-3.17.jar; poi-3.17.jar Main.java ExcelHandler.java CarDataModel.java

我用于运行的命令:

  

java -classpath poi-ooxml-3.17.jar; poi-3.17.jar Main

这是我的主要课程:

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        String vinNo,model,typeOfWork,problem,reason,removedPart,releasedPart,repairMan,informationSource,responsible;
        float torque;
        int option;
        Scanner scan=new Scanner(System.in);
        System.out.println("Enter (1) to write data or enter(2) to read data");
        option=scan.nextInt();
        scan.nextLine();
        if(option==1){
            System.out.println("Enter vinNo");
            while(true){
                vinNo=scan.nextLine();
                if(vinNo.length()!=17)
                    System.out.println("Invalid input please try again");
                else
                    break;
            }
            System.out.println("Enter model");
            model=scan.nextLine();
            System.out.println("Enter typeOfWork");
            typeOfWork=scan.nextLine();
            System.out.println("Enter problem");
            problem=scan.nextLine();
            System.out.println("Enter reason");
            reason=scan.nextLine();
            System.out.println("Enter removed part");
            removedPart=scan.nextLine();
            System.out.println("Enter released part");
            releasedPart=scan.nextLine();
            System.out.println("Enter repair man name");
            repairMan=scan.nextLine();
            System.out.println("Enter information source");
            informationSource=scan.nextLine();
            System.out.println("Enter responsible");
            responsible=scan.nextLine();
            System.out.println("Enter torque");
            while(true){
                String temp=scan.nextLine();
                try {
                    torque=Float.parseFloat(temp);
                    break;
                }catch (NumberFormatException e){
                    System.out.println("Invlid input please try again");
                }
            }


            ExcelHandler.writeToExcel(new CarDataModel(vinNo,model,typeOfWork,problem,reason,removedPart,releasedPart,torque,repairMan,informationSource,responsible));

        }
        else if(option==2){
            //FileHandler.readFromFile();
        }
    }
}

注意:我所有的文件都在同一个文件夹中

0 个答案:

没有答案