'"Missing JavaFX application class application.Main" when combining JavaFX with Apache POI
I am working on a JavaFX project that has to access encrypted Excel files. When trying to use WorkbookFactory.create(InputStream inp, String password) while the Stage is shown, i get an java.lang.NoClassDefFoundError: org/apache/poi/EncryptedDocumentException. So for testing i tried accessing an encrypted Excel file before showing the stage. But as a result i get a Missing JavaFX application class application.Main error. I can't even start debug mode.
I am using Windows 11, Eclipse Version: 2021-12 (4.22.0), JDK Version: jdk-17.0.2
package application;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;
public class Main extends Application {
@Override
public void start(Stage stage) {
try {
Parent root = FXMLLoader.load(getClass().getResource("MainScene.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
String filePath = "C:\\Path\\To\\Sheet\\Excel_Sheet.xlsx";
FileInputStream fis;
XSSFWorkbook workbook;
String password = "test";
try {
fis = new FileInputStream(filePath);
workbook = (XSSFWorkbook)WorkbookFactory.create(fis, password);
} catch (IOException | EncryptedDocumentException e) {
e.printStackTrace();
}
launch(args);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
