简体   繁体   中英

Running jar doesn't work

We are trying to make a jar out of our class files but somehow it does not work. The creation of the jar-file works fine with

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

But when we try to run it comes with a classnodefferror. Our application is using 2 property files - one for database and one for log4j.

The directory and the one subdirectory included looks like this: See link - image nr. 1 and 2

影像编号1

影像编号2

When we try to execute the jar file it shows this error: (See link image 3)

图片3

Normally when we run it, we type (see link image 4)

图片4

And the manifest-file looks like this (see link image 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.

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
  2. You can't use absolute paths in a JAR file - use relative paths instead

So, 1) change Manifest.txt to

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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