0

My MANIFEST.MF in my application jar contains the following line:

Class-Path: other.jar

My directoy contains the followign files at the same level:

- myApp.jar
- other.jar

I run my application using

java -jar myApp.jar

and get a NoClassDefFoundError for a class which is in other.jar

What am i missing please?

mangusbrother
  • 3,988
  • 11
  • 51
  • 103
  • did you try this post --> https://stackoverflow.com/questions/18413014/run-a-jar-file-from-the-command-line-and-specify-classpath – Lahiru Jayathilake Oct 01 '19 at 06:47
  • I am not specifying jar and cp as cmd line arguments. If anything i am using the answer in that post. my jar which is declard in my manifest.mf is ignored. – mangusbrother Oct 01 '19 at 06:49
  • can you try to give absolute path of jar in manifest.mf? – Pratik Oct 01 '19 at 06:53
  • still get the same error with an absolute path (and can't use absolute path either way as a final solution as this needs to work on several environments) – mangusbrother Oct 01 '19 at 06:57

2 Answers2

1

Turns out the issue was outside of the manifest file. I had an autogenerated index.list file next to it which blocks classpath from being read.

mangusbrother
  • 3,988
  • 11
  • 51
  • 103
0

Is your Class-Path the last line in the Manifest file?Then it should have an extra line at the end. It may not read the class-path if there is no carriage return in the end.

agupta
  • 11
  • 1