简体   繁体   English

导出的.jar上的Apache POI未在其他计算机上运行

[英]Apache POI on an exported .jar is not running on a different computer

I am currently developing a small application that reads and writes excel files for a form of sales report. 我目前正在开发一个小型应用程序,该应用程序可以读取和写入用于销售报告形式的excel文件。 This is all well and good, and the reading and writing works perfectly. 一切都很好,阅读和写作也很完美。 The issue I am running into is that this needs to be exported as an executable .jar to run from the desktop of other computers. 我遇到的问题是,需要将此文件导出为可执行文件。jar才能从其他计算机的桌面运行。 Exporting the .jar is simple, however when ran on a different computer, anytime one of my classes (ie "ExcelReader.java") reaches a point in the code that utilizes the Apache POI, the class crashes, but does not crash the entire code, in that the Main class ("Launcher") will still move through its main method and execute another class as it comes along, still crashing classes as it reaches usage of Apache POI. 导出.jar很简单,但是当在另一台计算机上运行时,只要我的一个类(即“ ExcelReader.java”)在使用Apache POI的代码中达到某个点,该类便会崩溃,但不会使整个崩溃代码,因为Main类(“ Launcher”)仍将遍历其main方法并随其执行另一个类,并在达到Apache POI用法时仍使类崩溃。 Any help would be greatly appreciated, and help understanding this issue even more so.This is a screenshot of my launcher class. 任何帮助将不胜感激,并且可以帮助您更好地理解此问题。这是我的启动器类的屏幕截图。 It will reach give me the first JOptionPane, then no give me any of the JOP's I have in reader. 它会给我第一个JOptionPane,然后不再给我我在阅读器中拥有的任何JOP。 However, it will proceed to the second JOP in Launcher and give me writer's JOP's UP UNTIL the first line of Apache POI code: 但是,它将继续进行Launcher中的第二个JOP,并为我的作者的JOP的UP UNTIL提供第一行Apache POI代码: 这是我的启动器类的屏幕截图。它会给我第一个JOptionPane,然后不再给我我在阅读器中拥有的任何JOP。但是,它将继续进行启动器中的第二个JOP,并为我的作者的JOP的UP UNTIL提供第一行Apache POI代码

Do the export boxes need to be highlighted for it to export with the jar file??? 导出框是否需要突出显示才能与jar文件一起导出????

If I had to guess, this is a ClassNotFound exception being thrown. 如果我不得不猜测,这是抛出的ClassNotFound异常。 Depending on how you are packaging the jar, it may or may not contain Apache POI as a dependency. 根据您包装jar的方式,它可能包含也可能不包含Apache POI作为依赖项。

Maven creates an uber jar where it opens up all jars and merges them together to create a single jar with all of the classes. Maven创建一个uber jar,在其中打开所有jar,并将它们合并在一起以创建一个包含所有类的jar。 You can look inside of the jar that you are exporting for the needed classes. 您可以在导出的jar中查看所需的类。

Here is a SO questions detailing how to create a single executable jar . 这是一个SO问题,详细说明了如何创建单个可执行jar There might be a couple more steps than just checking those libraries to be exported. 除了检查要导出的库外,可能还有其他几个步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM