简体   繁体   中英

how to use a jar To create a mac application?

I created a java project, when I execute my application from eclipse it works without any problems and no exception. I created a jar to execute it works on the computer that I used for the development, I tried on another pc, it only works if I execute java-jar program.jar in CMD. I tried to create an application mac (. App) using jarBundler using my jar. but the problem is that when I run the application it works, but it does not stop. In fact one of my button execute a script and a bar execution stops at the end of the execution. mac application that launches the script does not stop, if I try my script in terminal it works with the jar it works. I do not know what is the problem and how to detect it.

Try to incorporate logging (debug) messages into your code (especially the method that's not finishing execution as expected). Track the states of all objects that are critical for the method execution and compare the results on the different environments.

If you are using multiple Threads, add logging to track their states and make sure they end as expected and there are no deadlocks.

Regarding the differences in the environment (different OSes and console/UI execution), check all java specific environment variables, that would be JAVA_HOME, JAVA_OPTS etc. It's possible (though highly unlikely) that your UI and console user are using different env. variables.

If script for stop is not working in mac than you can made some changes in code and write script for close as it can work on both platform.

In case if could not get such code than you write different script for close for mac and other os so first you code for identifying the OS by code than run code by macthing according to OS.

Know OS Like:

public static boolean isWindows() {

        String os = System.getProperty("os.name").toLowerCase();
        // windows
        return (os.indexOf("win") >= 0);

    }

    public static boolean isMac() {

        String os = System.getProperty("os.name").toLowerCase();
        // Mac
        return (os.indexOf("mac") >= 0);

    }

can u clearify about the closing script. this will helpfull..

--Om--

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM