0

jar file

enter image description here

when I run java -jar main.jar I get the following error: enter image description here

The main class of the .jar file second.jar which is one of several libraries inside is not accessible.

I cannot rebuild the project since I just have the main.jar file.

How can I write a run.bat file or a mainifest.mf file that all .jar files that are contained in the main.jar file are accessible.

Here is the mainifest.mf file inside the main.jar:

enter image description here

Viktor Carlson
  • 989
  • 1
  • 13
  • 36

1 Answers1

0

There are following probable options for you to solve.

  1. Add all the required jar files in the Manifest.MF as given below.
Manifest-Version: 1.0
Main-Class: com.comapany.product.MainClass
Class-Path: a.jar b.jar c.jar
  1. You can run manually using the following command

java -cp a.jar;b.jar;c.jar com.comapany.product.MainClass

  1. It is highly recommended to create a fat jar using Maven Shade plugin in case of Maven or Shadow plugin in case of Gradle.
Sambit
  • 7,625
  • 7
  • 34
  • 65