Mac OS, Java Splash

2019-04-11 15:59发布

I'm trying to immigrate my Java application to Mac OS.
When the application start, splash screen supposed to appear.

When i running the App from the terminal it go like this:
java -classpath /the/right/classpath/ -splash:images/splash.png myApp/Main
when i do like this the splash screen appears.

But when i bundle the App with the Jar Bundler, the splash screen does not appear.

on the Jar Bundler, under the properties tab, in the VM Option i wrote:
splash:images/splash.png
I also tried:
-splash:images/splash.png(with hyphen).
I marked the option "Set Working Directory To Inside Application Package" as well.

i copy the images/splash.png to :

  • myApp.app/Contents
  • myApp.app/Contents/Resources
  • myApp.app/Contents/Resources/Java
  • myApp.app/Contents/MacOS
  • But the splash screen refuses to appear!

    It's strange because the myApp.app succeed to run - it just not show the splash screen.

    I found at the console this two messages:

    Feb 11 02:53:32 SnowL /Users/myusername/Desktop/myApp.app/Contents/MacOS/JavaApplicationStub[24262]: Unrecognized Java VM option ignored: -splash:images/splash.png

    This without hyphen before the splash attribute.

    Feb 11 02:55:50 SnowL /Users/myusername/Desktop/myApp.app/Contents/MacOS/JavaApplicationStub[26314]: Unrecognized Java VM option ignored: splash:images/splash.png

    How it can by that when i run the app from the terminal the splash screen appear, but double click on the App does not show the splash screen?
    it supposed to run on the same VM like the terminal VM, doesn't it?
    I olso change the JVM version (on the Info.plist file) to:
    1.5*
    1.5+
    1.6*
    1.6+
    none of them make the splash screen to appear.

    Thanks for help!

    4条回答
    我欲成王,谁敢阻挡
    2楼-- · 2019-04-11 16:11

    Like this, in your Info.plist:

    ...
    <key>Java</key>
        <dict>
    
        <key>MainClass</key>
        <string>...</string>
    
        <key>SplashFile</key>
        <string>$APP_PACKAGE/tmp_splash.png</string>
    ...
    
    查看更多
    贪生不怕死
    3楼-- · 2019-04-11 16:14

    You could make your application show a jFrame with decorations off and your picture at the start up of the application

    查看更多
    叼着烟拽天下
    4楼-- · 2019-04-11 16:15

    I had the same problem, and found a solution on this thread:

    http://lists.apple.com/archives/java-dev/2008/Jun/msg00012.html

    It involves adding an entry to the bundled application's Info.plist file after using Jar Bundler. Also, the image needs to be copied to myApp.app/Contents/Resources/Java (at least with the "set working directory inside application package" option). There's probably a better way, but this seems to work.

    查看更多
    beautiful°
    5楼-- · 2019-04-11 16:22

    In my application:
    Info.plist:

        ...
        <dict>
            <key>ClassPath</key>
            <string>$JAVAROOT/@PROJECTNAMEASIDENTIFIER@.jar:@CLASSPATH@</string>
            <key>JVMVersion</key>
            <string>1.6+</string>
            <key>MainClass</key>
            <string>@PROJECTMAINCLASS@</string>
            <key>SplashFile</key>
            <string>$JAVAROOT/splash.png</string>
        ...  
    

    Copy splash.png to myapp.app/Contents/Resources/Java/splash.png
    et voila.

    查看更多
    登录 后发表回答