Java and Mac retina support

I just tested this on my MacBook Pro with retina, so the answer is yes and no - at least under Mountain Lion.

If you use Java directly from the command line, the answer is yes: it will launch in HiDPI and render text in high resolution. Things rendered using Graphics2D will render in high resolution mode. (So if you render a line 0.5 AWT pixels thick and place it at 0.25/0.75 off an AWT pixel, it will render a single "retinal pixel" thick.) Likewise, rendering an image at half-resolution will render it at "retinal" resolution.

So instead of just g.drawImage(image, x, y, observer) you'd need to do:

g.drawImage(image, x, y,
    image.getWidth(observer)/2,
    image.getHeight(observer)/2, observer);

(Unless you have an odd width/height, in which case you should probably use Graphics2D and just scale(0.5, 0.5) to render a retinal image.)

If you use JavaApplicationStub, then you need the answer provided by Matt Solnit, otherwise it will launch in the "scaled" mode. (Under Mountain Lion, there are added hoops to jump through related to Gatekeeper, but that's a different question.)

Note that this answer applies to both Mountain Lion and the Apple-provided version of Java for it (Java 1.6.0_33). It might be different under Oracle's Java 7 for Mac OS X, and it may not work the same way under Lion.


Apple's Java 6 JRE will support HiDPI, however it is not currently supported by Oracle's Java 7 JRE. It also doesn't work under the latest dev builds of Java 8. Swing and JavaFX apps are blurry on a Retinia MacBook. This is why IntelliJ still runs under Java 6. Eclipse applications will require the PList mode that Jurriaan Mous mentioned. The milestone builds of Eclipse 4.3 don't require the edit.


From: https://bugs.eclipse.org/bugs/show_bug.cgi?id=382972

Here's the workaround:

Do "Show package contents" on the Eclipse.app. Edit Contents/Info.plist using your favorite text editor. Just above

</dict>
</plist>

Place this:

<key>NSHighResolutionCapable</key>
<true/>

Then, navigate to the folder Eclipse is stored in and execute

touch Eclipse.app

to make macOS notice the change.

Now, the info window will not show "Open in Low Resolution" as checked. Launch Eclipse and enjoy your new retina awesomeness.


It's likely treated as unmodified, given the number of questions asking about how Eclipse looks and how to make it look better. (Eclipse runs on Java.)


At the store I wrote a HelloWorld in Swing, and text looked correctly Retina-sharp. (Didn't try SWT, which requires more downloading to setup.)