I have the following structure:
myapp.jar
lib/
myapp.jar
is an executable jar that includes a splash screen image resource and uses the SplashScreen-Image
manifest entry. lib/
contains a bunch of other jar files.
If I run java -jar myapp.jar
, the splash screen is displayed but (as expected) the program can't find its dependencies in lib/
.
If I run java -cp myapp.jar:lib/* mypackage.MainClass
, it finds its dependencies but the splash screen is not shown. SplashScreen.getSplashScreen()
returns null.
If I run java -cp myapp.jar:lib/* -splash:images/splash.jpg mypackage.MainClass
, the splash screen still doesn't work. Apparently it's treating images/splash.jpg
as a relative filesystem path, not a classpath resource.
Trying to combine -cp
with -jar
, i.e., java -cp myapp.jar:lib/* -jar myapp.jar
behaves exactly like java -jar myapp.jar
. -cp
is apparently ignored with -jar
.
Is there any solution besides supplying the splash image separately from the executable jar?
You can add a Class-Path
entry to your jar manifest, so you can use the -jar
option while still finding your dependencies.