Jar выдает ошибки из Java-проекта, который работает нормальноJAVA

Программисты JAVA общаются здесь
Anonymous
Jar выдает ошибки из Java-проекта, который работает нормально

Сообщение Anonymous »


I have made a little project, which I try to convert into exe file now. And to do so I need to make a jar file first, where the problems arise:

Here is what jar program throws.

C:> C:\[path]\IdeaProjects\Erpegkraj\out\artifacts\Erpegkraj_jar\Erpegkraj.jar ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console... Exception in thread "main" java.lang.ExceptionInInitializerError at Erpegkraj.Grafika.MenuGłówne.(MenuGłówne.java:26) at Erpegkraj.PanelGry.(PanelGry.java:63) at Erpegkraj.Interfejs.main(Interfejs.java:39) Caused by: org.apache.poi.openxml4j.exceptions.InvalidOperationException: Can't open the specified file input stream from file: 'zasoby\Dane\Dane.xlsx' at org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:188) at org.apache.poi.openxml4j.opc.ZipPackage.(ZipPackage.java:175) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:285) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:192) at Erpegkraj.ZarządcaArkuszów.przeczytajWierszArkusza(ZarządcaArkuszów.java:24) at Erpegkraj.Postacie.Bohater.(Bohater.java:39) at Erpegkraj.Postacie.Bohaterowie.Krzyżowiec.(Krzyżowiec.java:13) at Erpegkraj.Grafika.DaneWMenu.Bohaterowie$1.evaluate(Bohaterowie.java:15) at Erpegkraj.Grafika.DaneWMenu.Bohaterowie.(Bohaterowie.java:20) ... 3 more Caused by: java.io.FileNotFoundException: zasoby\Dane\Dane.xlsx (System nie może odnaleźć określonej ścieżki) at java.base/java.io.FileInputStream.open0(Native Method) at java.base/java.io.FileInputStream.open(FileInputStream.java:213) at java.base/java.io.FileInputStream.(FileInputStream.java:152) at org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:185) ... 11 more It keeps saying that it can't open a file (an excel file) in my resources folder (which is called zasoby).

This is a part of code I think it has problems with:

public static String readSheetsLine(File sheetsPath, String sheetsName, String name) throws IOException { String text = ""; OPCPackage package; Workbook wb; try { package = OPCPackage.open(sheetsPath); wb = new XSSFWorkbook(package); } catch (InvalidFormatException e) { throw new RuntimeException(e); } Sheet sheet = notatnik.getSheet(sheetsName); for(Row r: sheet){ String value = r.getCell(0).getStringCellValue(); if(Objects.equals(value, nazwa)){ for (Cell c : r){ c.setCellType(CellType.STRING); String typ = sheet.getRow(0).getCell(c.getColumnIndex()).getStringCellValue(); if (!Objects.equals(typ, "")){ tekst += typ + "#"+ c.getStringCellValue()+"~"; }else break; } break; } if (Objects.equals(value, "")) break; } wb.close(); package.close(); return text; } I have tried everything I could find on the Internet about "InvalidOperationException", but nothing prevailed.

I would be thankful for any kind of help.


Источник: https://stackoverflow.com/questions/781 ... -just-fine

Вернуться в «JAVA»