软件包org.apache.poi.ss.usermodel不存在

时间:2018-12-17 06:03:10

标签: java cmd jvm

我尝试使用CMD编译Java文件,但出现这些错误。我已经遵循了其他关于stackoverflow的解决方案,但是仍然没有解决。

C:\Users\User\eclipse-workspace\Calendar_v1\src\cal>javac ShiftSetting.java

ShiftSetting.java:7: error: package org.apache.poi.ss.usermodel does not exist
import org.apache.poi.ss.usermodel.Cell;
                                  ^
ShiftSetting.java:8: error: package org.apache.poi.ss.usermodel does not exist
import org.apache.poi.ss.usermodel.DataFormatter;
                                  ^
ShiftSetting.java:9: error: package org.apache.poi.ss.usermodel does not exist
import org.apache.poi.ss.usermodel.Row;
                                  ^
ShiftSetting.java:10: error: package org.apache.poi.xssf.usermodel does not exist
import org.apache.poi.xssf.usermodel.XSSFSheet;
                                    ^
ShiftSetting.java:11: error: package org.apache.poi.xssf.usermodel does not exist
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
                                    ^
ShiftSetting.java:21: error: cannot find symbol
                        XSSFWorkbook wb = new XSSFWorkbook(file);
                        ^
  symbol:   class XSSFWorkbook
  location: class ShiftSetting
ShiftSetting.java:21: error: cannot find symbol
                        XSSFWorkbook wb = new XSSFWorkbook(file);
                                              ^
  symbol:   class XSSFWorkbook
  location: class ShiftSetting
ShiftSetting.java:22: error: cannot find symbol
                        XSSFSheet sheet = wb.getSheetAt(0);
                        ^
  symbol:   class XSSFSheet
  location: class ShiftSetting
ShiftSetting.java:24: error: cannot find symbol
                        DataFormatter formatter = new DataFormatter();
                        ^
  symbol:   class DataFormatter
  location: class ShiftSetting
ShiftSetting.java:24: error: cannot find symbol
                        DataFormatter formatter = new DataFormatter();
                                                      ^
  symbol:   class DataFormatter
  location: class ShiftSetting
ShiftSetting.java:29: error: cannot find symbol
                                Row r = sheet.getRow(rowNum);
                                ^
  symbol:   class Row
  location: class ShiftSetting
ShiftSetting.java:32: error: cannot find symbol
                                        Cell cell = r.getCell(m);
                                        ^
  symbol:   class Cell
  location: class ShiftSetting
ShiftSetting.java:39: error: cannot find symbol
                                Row r = sheet.getRow(rowNum);
                                ^
  symbol:   class Row
  location: class ShiftSetting
ShiftSetting.java:43: error: cannot find symbol
                                        Cell cell = r.getCell(m);
                                        ^
  symbol:   class Cell
  location: class ShiftSetting
14 errors

这是我要编译的ShiftSetting.java文件

 package cal;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ShiftSetting {
    public static void main(String[] args) {
    // code
    }
}

我已将所有APACHE-POI jar文件导入到我的Java构建路径中

enter image description here

我也将这些路径添加到用户环境变量中

enter image description here

谁能告诉我现在应该尝试哪种方法?因为我不知道该怎么办。

1 个答案:

答案 0 :(得分:0)

我的问题是类路径。经过几次尝试后,我现在可以像这样在一行中编译所有8个jar文件:

C:\Users\User\eclipse-workspace\Calendar_v1\src\cal>javac -cp jars/dom4j-1.6.1.jar;jars/poi-3.2-final.jar;jars/poi-3.7.jar;jars/poi-examples-3.7.jar;jars/poi-ooxml-3.7.jar;jars/poi-ooxml-schemas-3.7.jar;jars/poi-scratchpad-3.7.jar;jars/xmlbeans-2.3.0.jar ShiftSetting.java

问题已解决(顺便说一句,这是针对窗口的)