Running out of ideas on the cause of the issue. I have a java jar (built from gradle under intellij if that matters).
Jar has a manifest.
Launching
java -jar MyJar.jar
from directory containing jar gives "could not find or load main class companyname.mainclass"Java is reading from manifest as Editing the manifest file inside jar to
mainclass2
will change the name in the error messageManifest contains only version on a line, then main class attribute on a line, then 2 blank lines
All dependencies are in a /lib folder relative to jar so no classpath specified in manifest
Opening jar in zip file program shows folder
companyname
with file in itmainclass
so the qualified name is reflected in jar structure. Capitalisation is also correct.Manually specifying class name
java -cp MyJar.jar companyname.mainclass
gives the same class not found errorThe class in question does have a main method, and does run fine under the IDE when unpackaged.
What am I missing (apart from more and more chunks of hair off my head)?
Edit Additional details: - using Java 8
jar structure:
-META-INF
MANIFEST.MF
-companyname
-module
-interfaces
interface1.class
-commands
baseCommand.class
register.class
specialCommand.class
moduleSpec.class
moduleProcessor.class
mainclass.class
log4j.xml
springconfig1.xml
springconfig2.xml
Manifest file:
Manifest-Version: 1.0
Main-Class: companyname.mainclass
(newline char here)
(newline char here)