문제

I wrap my Java Swing application as an exe using Jsmooth but I can see no way to take advantage of Java 6 splash screen option. I have the following manifest file:

     Manifest-Version: 1.0

     SplashScreen-Image: resources/LOADLOGO.png

     Main-Class: se.bookingapp.UI.MainFrame

The splash screen appears if I simply click on the jar file of the application. However, the JSmooth generated exe form of the jar file does not show the splash screen somehow. Does anyone know why?

도움이 되었습니까?

해결책

Does it work when you execute the jar file? Open it with WinRar for example, and check if the manifest is into META-INF folder, and LOADLOGO.png is in the right folder too.

After doing that, it should work. It works for me. Nothing wrong in your manifest.

다른 팁

Yesterday I've finished to develop my java application and I had the same issue. If I double click the .jar file or I execute in a command line splash screen works perfectly, but when I execute the wrapped file it doesn't. Seems just JSmooth doesn't support this feature.

However I made a little trick to have a wrapped .exe and splash screen working at the same time. I made a little application called ApplicationLoader.jar that consists in a single main class that execute java -jar "Application.jar" in a command line. Here is the complete code:

public class ApplicationLoader {
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {        
    /* First I check if the first parameter is not null and it's not an empty string */
    if(args[0] != null && !args[0].trim().isEmpty()){
        /* Then I use java.util.regex package to validate the parameter is a .jar file */
        Pattern pattern = Pattern.compile(".*jar");
        Matcher matcher = pattern.matcher(args[0]);            
        if(matcher.matches()){
            /* Finally I define the command line like: java -jar "Application.jar" */
            String command = "java -jar \"" + args[0] + "\"";
            try {
                Runtime r = Runtime.getRuntime();
                ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/c", command);
                Process p = pb.start();
                p.waitFor();
                } catch (IOException | InterruptedException ex) {
                   JOptionPane.showMessageDialog(null, ex.getMessage(), "Error executing: "+command, JOptionPane.ERROR_MESSAGE);
                }                
        } else {
            JOptionPane.showMessageDialog(null, "The argument is not a .jar file!!");
        }            
    } else {
        JOptionPane.showMessageDialog(null, "There's not a valid argument!");
    }
}
}

I have this folder structure for my application:

MyApp
  +-- bin
  |    +-- MyApp.jar
  |    +-- ApplicationLoader.jar
  +-- MyApp.exe

So in JSmoot I changed the classpath to ApplicationLoader.jar and add the relative location to my application in Application Arguments section like this:

enter image description here

And that's it. I know this is not the best option but is a workaround.

However there's a little problem:

Since ApplicationLoader.jar calls a cmd.exe then the wrapped .exe and your application will execute in two different processes.

This implies that if you have to kill .exe process for some reason (unexpected crash or something), your java application still working as a java.exe process. So in that case you must kill MyApp.exe and java.exe processes. Actually if you just kill java.exe process then MyApp.exe process will finish execution by itself.

If you keep this in mind and you can live with that I think this option is quite simple and useful. I hope this be helpful to anybody looking for a workaround to this issue.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top