错误:无法find或加载主类excel2JSON.excel

package excel2JSON; import java.io.File; import java.io.FileInputStream; import java.util.Iterator; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.json.JSONArray; import org.json.JSONObject; public class excel { public static void main(String[] args) { String str = ExcelToJSON(new File ("C:\\workbook.xlsx")); System.out.println("JSON = " + str); } private static String ExcelToJSON(File file_open) { JSONObject json = null; try { FileInputStream input = new FileInputStream(file_open); Workbook workbook = WorkbookFactory.create(input); Sheet sheet = workbook.getSheetAt(0); json = new JSONObject(); JSONArray rows = new JSONArray(); for (Iterator<Row> rows_it = sheet.rowIterator(); rows_it.hasNext();) { Row row = rows_it.next(); JSONObject jason_row = new JSONObject(); JSONArray cells = new JSONArray(); for (Iterator<Cell> cells_it = row.cellIterator(); cells_it.hasNext();) { Cell cell = cells_it.next(); //Check the cell type and format accordingly switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: double numeric=cell.getNumericCellValue(); cells.put(String.valueOf(numeric)); break; case Cell.CELL_TYPE_STRING: cells.put(cell.getStringCellValue()); break; } } jason_row.put("cell", cells); rows.put(jason_row); } // Create the JSON. json.put("rows", rows); } catch (Exception e) { e.printStackTrace(); } // Get the JSON text. return json.toString(); } } 

得到这个错误:

错误:无法find或加载主类excel2JSON.excel

我不知道为什么我得到这个错误。 我是Java的新手,我需要帮助来解决这个问题。 我正试图将Excel文件转换为JSON文档。 这是我写的代码,但我得到问题,当我在Eclipse中运行程序。

在eclipse中这个错误的最常见的原因是当你移动了类时,Eclipse将尝试使用过时的运行configuration,这将不起作用。

单击Eclipse中绿色播放button旁边的向下箭头,select运行configuration。

删除对这个类的引用,然后closures那个窗口,selectexcel类。 再次单击播放button旁边的向下箭头,然后select作为Java应用程序运行。