2

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?

1
  • Thanks everyone! The correct code ended up being: ` if (System.getProperty("os.name").equals("Mac OS X")) { System.setProperty("apple.laf.useScreenMenuBar", "true"); }` Commented Aug 3, 2010 at 19:51

4 Answers 4

1

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")
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

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.

Comments

0

I would suggest that you bundle the .jar into a standard mac .app file. Then, in Info.plist, you can specify all sorts of runtime items, including "Arguments" and "Properties". Take a look at http://developer.apple.com/library/mac/#documentation/Java/Reference/Java_InfoplistRef/Articles/JavaDictionaryInfo.plistKeys.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.