0

I have three java classes, a, b, and c in the current working folder.

Class c needs a library(library.jar) in sub-folder called lib. So I have folder structure as follows…

a.class
b.class
c.class
lib/library.jar

To create the MANIFEST.MF I create MANIFEST.TXT with two standard key/value pairs…

Main-Class: a
Class-Path: lib/library.jar

To create an executable jar, with MANIFEST.MF, I do the command…

jar cvfm executable.jar MANIFEST.TXT *.class lib/library.jar

The command above means executable.jar contains my classes and lib/library.jar (i.e. the complete folder structure within it).

But to deploy executable.jar, you have to have the executable.jar as well as create an external folder, lib with library.jar in it, i.e.

lib/library.jar
executable.jar

INSTEAD OF just the executable only…

executable.jar

Isn’t there a programmatical way to make java search in the path already within the excutable jar itself ???

lazyone
  • 1
  • 3
  • 1
    No. You cannot search for jars in a jar. You would need to unpack the lib and then jar the whole lot - known as a “fat” or “Uber” jar. – Boris the Spider Nov 20 '21 at 09:44
  • 2
    I highly recommend using a build tool like Maven or Gradle. With shadow plugins, you can create a "fat jar" that contains everything to run your application very easily. – McPringle Nov 20 '21 at 09:50
  • Boris, does it therefore mean, I can skip adding lib/library.jar into executable.jar ?? because I know I will provide it in an external folder anyway ?? – lazyone Nov 20 '21 at 09:58
  • Basically, yes. – Stephen C Nov 20 '21 at 10:05

0 Answers0