简体   繁体   English

运行jar不起作用

[英]Running jar doesn't work

We are trying to make a jar out of our class files but somehow it does not work. 我们正在尝试用我们的类文件制作一个jar,但是它不起作用。 The creation of the jar-file works fine with jar文件的创建可以与

jar -cvfm client.jar Mainfest.txt /home/pi/Desktop/Client/*.class

But when we try to run it comes with a classnodefferror. 但是,当我们尝试运行它时,会出现classnodefferror。 Our application is using 2 property files - one for database and one for log4j. 我们的应用程序使用2个属性文件-一个用于数据库,一个用于log4j。

The directory and the one subdirectory included looks like this: See link - image nr. 目录和包含的一个子目录如下所示:请参阅链接 -image nr。 1 and 2 1和2

影像编号1

影像编号2

When we try to execute the jar file it shows this error: (See link image 3) 当我们尝试执行jar文件时,它显示此错误:(请参见链接图像3)

图片3

Normally when we run it, we type (see link image 4) 通常,当我们运行它时,我们会键入(请参阅链接图像4)

图片4

And the manifest-file looks like this (see link image 5) 清单文件看起来像这样(请参见链接图像5)

图片4

We have tried different solutions like changing paths, leaving out environment (-D) etc. and we really can't figure out what we do wrong. 我们尝试了不同的解决方案,例如更改路径,忽略环境(-D)等,但我们真的无法弄清楚我们做错了什么。

There are several problems here: 这里有几个问题:

  1. It is better to explicitly mention each included JAR file in the manifest - wildcards like * isnt working too well 最好在清单中明确提及每个包含的JAR文件-像*这样的通配符不能很好地工作
  2. You can't use absolute paths in a JAR file - use relative paths instead 您不能在JAR文件中使用绝对路径-而是使用相对路径

So, 1) change Manifest.txt to 因此,1)将Manifest.txt更改为

Main-Class: Client
Class-Path: . includes/log4j-1.2.17.jar includes/mysql-connector-java-5.1.33-bin.jar includes/sqlitejdbc-v056.jar includes/RXTXcomm-2.2pre2.jar  includes/..... (repeat for all pi4j JAR files)

And, 2) copy ALL the JAR files you need (including RXTXcomm-2.2pre2.jar and the pi4j JARs) into the include/ subdirectory, and change command to 并且,2)将您需要的所有JAR文件(包括RXTXcomm-2.2pre2.jar和pi4j JAR)复制到include /子目录中,并将命令更改为

jar -cvfm client.jar Manifest.txt *.class *.properties includes/*

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

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