Jar files have a "class-path" manifest entry which defines the class path Java should use to find dependencies. I believe -cp will override this, but it's been so long since I tried anything like this I could be wrong. Besides, -cp is only defining a single entry, it should be listing ALL the Jar's, which why it's better to use the Jar class-path manifest entry
Kernel.class.getResourceAsStream(resource); Not nearly enough information to help solve this. What is the value of resource? What is the listing of the Jar content (see comment of @ThorbjørnRavnAndersen)? For better help sooner, post a minimal reproducible example or Short, Self Contained, Correct Example.
-cpwill override this, but it's been so long since I tried anything like this I could be wrong. Besides,-cpis only defining a single entry, it should be listing ALL the Jar's, which why it's better to use the Jarclass-pathmanifest entryjar tvf myjar.jarfor the resource files. Also be certain you have a leading "/" in yourresource.Kernel.class.getResourceAsStream(resource);Not nearly enough information to help solve this. What is the value ofresource? What is the listing of the Jar content (see comment of @ThorbjørnRavnAndersen)? For better help sooner, post a minimal reproducible example or Short, Self Contained, Correct Example.