Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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.</p> <p>However I made a little trick to have a wrapped <code>.exe</code> and splash screen working at the same time. I made a little application called <code>ApplicationLoader.jar</code> that consists in a single main class that execute <code>java -jar "Application.jar"</code> in a command line. Here is the complete code:</p> <pre><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 &amp;&amp; !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!"); } } } </code></pre> <p>I have this folder structure for my application:</p> <blockquote> <pre><code>MyApp +-- bin | +-- MyApp.jar | +-- ApplicationLoader.jar +-- MyApp.exe </code></pre> </blockquote> <p>So in <code>JSmoot</code> I changed the classpath to <code>ApplicationLoader.jar</code> and add the relative location to my application in <em>Application Arguments</em> section like this:</p> <p><img src="https://i.stack.imgur.com/WBikK.jpg" alt="enter image description here"></p> <p>And that's it. I know this is not the best option but is a workaround.</p> <p>However there's a little problem:</p> <p>Since <code>ApplicationLoader.jar</code> calls a <code>cmd.exe</code> then the wrapped <code>.exe</code> and your application will execute in two different processes.</p> <p>This implies that if you have to kill <code>.exe</code> process for some reason (unexpected crash or something), your java application still working as a <code>java.exe</code> process. So in that case you must kill <code>MyApp.exe</code> and <code>java.exe</code> processes. Actually if you just kill <code>java.exe</code> process then <code>MyApp.exe</code> process will finish execution by itself.</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload