简体   繁体   English

使用外部JavaPOS文件导出到JAR

[英]Export to JAR with external JavaPOS Files

I've currently finished my project, but can't get it to work when it is exported. 我目前已经完成了我的项目,但是在导出时无法使其正常工作。 I use JAXB to read and write XML Files and also have dependencies on other external Folders, which are needed to use a POS-Printer. 我使用JAXB读写XML文件,并且还依赖于其他外部文件夹,这是使用POS打印机所必需的。

I've managed to link my external XML Save-Files with absolute paths, but not with relative paths. 我设法用绝对路径链接我的外部XML保存文件,但没有相对路径。 So that worked, although not the way i wanted. 这样就行了,尽管不是我想要的方式。 Yet, using the external class folder for the printer didn't work at all. 但是,将外部类文件夹用于打印机根本不起作用。

This means, that in my Eclipse Project Build Path i've added a class folder, which contains all of these needed files (which are not only jars, so adding them one by one wouldnt work). 这意味着,在我的Eclipse项目构建路径中,我添加了一个类文件夹,其中包含所有这些需要的文件(不仅是jar,因此一个接一个地添加它们是行不通的)。 So exporting my project to a jar either includes all the files into the jar itself, or doesnt include them at all. 因此,将我的项目导出到jar中时,要么将所有文件都包含在jar中,要么根本不包含它们。 Everything works perfectly in Eclipse, but not when i export it. 一切都可以在Eclipse中完美运行,但是当我导出时却不能。

My folder structure looks like this: 我的文件夹结构如下所示:

src
   /model
   /view
   /control
data
   /articles.xml
   /...
JavaPOS  <--- needed folder with all its files
   /jpos.xml
   /xerxers.jar
   /swt-..-.dll

I've tried: 我试过了:

  • InputStreams is = getClass().getResourceAsStream(url); InputStreams是= getClass()。getResourceAsStream(url);

  • absolute paths 绝对路径

  • manipulating the manifest file and/or jar structure 操作清单文件和/或jar结构

  • runnable and non runnable jars with nearly every combination of options 具有几乎所有选项组合的可运行罐和不可运行罐

  • putting the files inside the library "by hand" 手动将文件放入库中

  • changing the build path of the project 更改项目的构建路径

My Question is: 我的问题是:

How do i get my jar-file to know where these files are? 我如何使我的jar文件知道这些文件在哪里?

EDIT: 编辑:

Do you think Maven or an Ant file could solve my problems? 您认为Maven或Ant文件可以解决我的问题吗? I don't have any experience with those. 我没有任何经验。

The Problem was, that i had more than one JRE installed and that the one eclipse was using, had all the dll files, but the other ones didnt have it. 问题是,我安装了多个JRE,一个eclipse正在使用,具有所有的dll文件,而另一个则没有。 So i had to add them manually, because reinstalling the drivers of the printer didnt change anything. 所以我不得不手动添加它们,因为重新安装打印机的驱动程序并没有改变任何东西。 Gotta fix that somehow, but right now it works and that is all i wanted. 必须以某种方式解决该问题,但是现在它可以工作,这就是我想要的。

Turns out i didn't even need that Folder, just needed one file out of it and the missing dlls. 原来我什至不需要那个文件夹,只需要其中一个文件和缺少的dll。

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

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