Is it currently possible to enable the mac's integrated graphics chip in a Java application?

Unfortunately, what you want is not possible using Java 7.

Some sources from around the web:

  • http://mail.openjdk.java.net/pipermail/macosx-port-dev/2012-September/004863.html
  • http://support.apple.com/kb/ts4044

You already mentioned gfxCardStatus, but that seems to be the only way

Theoretically you can disable OpenGL support, however this is not enough for it to not trigger that java needs discrete graphics. It appears that as part of the evaluation as to whether or not it should use openGL, it tickles the GPU, and the mac decides that it must fire up the discrete GPU for the lifetime of that application.

edit: it appears that not even gfxCardStatus can prevent the switch anymore.


There is a special option which has to be specified in the Info.plist file of the launcher of the application:

<key>NSSupportsAutomaticGraphicsSwitching</key><true/>

This gives a Java application the power of using the integrated card. Otherwise the system uses the discrete graphics by default. Unfortunately this option is not included in the standard JVM distribution from Oracle.


Update as of 2019-08-01: The newest generally available macOS + Java today is: macOS 10.14.6 Mojave + Java Version 8 Update 221 Build 1.8.0_221-b11

Setting NSSupportsAutomaticGraphicsSwitching to TRUE indeed prevents the enforced use of discrete GPU usage! But not for all Java apps! I tested these:

jdiskreport 1.4.1: After having added NSSupportsAutomaticGraphicsSwitching=TRUE to the Info.plist it then launches with the internal GPU and functions normally!

FreeMind 1.0.1: Info.plist was shipped with NSSupportsAutomaticGraphicsSwitching=TRUE and NSHighResolutionCapable=TRUE. Removing JVMRuntime=jdk1.7.0_45.jdk starts the app with the iGPU indeed but then does not work. You see the startup dialog ("Freemind 1.0.1": Initializing this, that, bla bla) until the app is ready. But you then only see the main menu (the application stub I guess). No new/recent file opened in a window. As soon as you want to open/create a new file, the creation of a window fails: Short flash and the main menu (the application stub I guess) re-renders shortly. I will ask over at FreeMind what can be done.

Tags:

Java

Macos

Gpu