0

I've exported my java program to a runnable jar file, and it works great except for a few methods. When I use apple's methods such as..

System.setProperty("apple.laf.useScreenMenuBar", "true");

..and..

Toolkit.getDefaultToolkit().getDesktopProperty("apple.awt.contentScaleFactor");

..they work in eclipse, but don't run in the runnable jar. How do I fix this?

Kara
  • 6,115
  • 16
  • 50
  • 57
Tyler
  • 486
  • 1
  • 6
  • 20

1 Answers1

1

It's difficult to know why from the snippets, but, according to Java Runtime System Properties you could pass them as part of the Java command,

java -Dapple.laf.useScreenMenuBar="true" com.example.yourApp

Or set them as part of the System.setProperty, but you should do so before any part of the AWT/Swing libraries have had a chance to be initialised.

When setting a property within your application (using System.setProperty), make sure that it is one of the first statements made inside of your main method. Doing so sets the property before AWT is loaded, ensuring that it takes effect.

Or you could package your app as an app bundle, then you could supply the setting as part of the Info.plist as demonstrated here

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366