Hello I am getting the following exception when running the jar. Can somebody help please?
U2007750s-MacBook-Pro:target u2007750$ java -jar ExcelCSVConverter-0.0.1-SNAPSHOT.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Cell
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Cell
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
UPDATE:
Until now I only had the poi-ooxml
dependency in the pom.xml:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
The program executes correctly in eclipse. It's only in the command line where the error occurs.
Now after recommendation of you guys, I have also added the second dependency poi
:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
but still not success. Now the error occurs for this class:
U2007750s-MacBook-Pro:target u2007750$ java -jar ExcelCSVConverter-0.0.1-SNAPSHOT.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/impl/values/XmlValueOutOfRangeException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
The method is:
private static String getCellData(XSSFCell myCell) {
String cellData = "";
if (myCell == null) {
cellData += CSV_SEPERATOR_CHAR;
} else {
try {
switch (myCell.getCellTypeEnum()) {
case STRING:
case BOOLEAN:
cellData += myCell.getRichStringCellValue() + CSV_SEPERATOR_CHAR;
break;
case NUMERIC:
cellData += getNumericValue(myCell);
break;
case FORMULA:
cellData += getFormulaValue(myCell);
default:
cellData += CSV_SEPERATOR_CHAR;
}
} catch (XmlValueOutOfRangeException e) {
int a =2;
//System.out.println("XmlValueOutOfRangeException for: "+ myCell.getRawValue());
String rawValue = myCell.getRawValue();
while(rawValue.startsWith("0")) {
rawValue = rawValue.substring(1);
}
cellData += rawValue+ CSV_SEPERATOR_CHAR;
}
}
return cellData;
}