1

Haven't been able to find how to do this without an IDE (got this far without one).

I have a couple libraries I imported into my code, here are a few examples.

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

I have the following file structure:

  • root dir = RackSerials
    • sub dir lib - where all .jar import files are included
    • sub dir tdms - all my .class files

I tried including all the .jar files in my manifest

Main-Class: tdms.rackserials
Class-Path: lib.commons-collections4-4.2.jar lib.commons-compress-1.18.jar lib.json-20180813.jar lib.json-simple-1.1.1.jar lib.poi-4.0.0.jar lib.poi-ooxml-4.0.0.jar lib.poi-ooxml-schemas-4.0.0.jar lib.xmlbeans-3.0.1.jar

However if I move my JAR to another computer (that does not have the required libraries installed) it errors out with:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/WorkbookFactory

I found this NOTE in another thread.. so how do I include those other JAR files (the imported libraries) to make my package portable?

Note: The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over Internet protocols. To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes. For example, if MyJar.jar contains another JAR file called MyUtils.jar, you cannot use the Class-Path header in MyJar.jar's manifest to load classes in MyUtils.jar into the class path.

David
  • 13
  • 1
  • 7
  • You can assemble zip file with your own jar and lib directory with all dependencies and ship that zip – Ivan Nov 17 '18 at 04:57

0 Answers0