views:

51

answers:

3

I am making a Java application that is stored in a .jar file and can be launched by opening the jar file either from the command line or from clicking the icon.

For the Mac version of the app, I would like the menu bars to appear at the top of screen in the Mac style instead of in the window (the Windows style). I know this can be done with the command line:

java -jar App.jar -Dcom.apple.macos.useScreenMenuBar=true

But this won't work if the user doesn't know how to do this. Is there a way to make this command line argument "built in" to the jar file?

A: 

Is is necessary to do it with the command line? You could check it in code with System.getProperty("os.name").

InsertNickHere
A: 

Inside my main method, I would make use of the built in os.name parameter and default your command line argument as appropriate if it was not otherwise set.

Mike Clark
+1  A: 

You can do this by setting the system property in your code in the main method or some other method which is called at the very beginning of the application:

System.setProperty("com.apple.macos.useScreenMenuBar", "true")
abhin4v