6

Does Java support the retina display with high definition rendering of, for example, text? Or is it treated as an unmodified application, and therefore subject to scaling?

3

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.

  • That works for me as well. I wrote an app that creates a system tray icon. According to SystemTray.getSystemTray().getTrayIconSize() the dimension is 22 x 22 (as in a MacBook without retina display). However, if I add a 64 x 64 pixel image it draws just fine. – Thomas Mueller Sep 6 '12 at 19:32
  • 2
    On a 15" rMBP my experience is that for the most part, Java applications/applets "just work" with retina IF you're using Apple's JVM (1.6). Using Oracle's Java 1.7, everything is blurry. – drootang Dec 4 '12 at 17:59
6

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.

5

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.

  • This is a great tip, but doesn't actually answer my question. I really want to know about native java applications, and applets, not only Eclipse… That said, it is great to know that I can make Eclipse work! – Paul Wagland Jun 23 '12 at 1:13
1

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.)

  • 1
    Note that Eclipse is based on SWT, not Swing, so although based on Java, the graphics are most definitely not. – Paul Wagland Jun 14 '12 at 21:33
1

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.)

0

I don't have a MBP Retina, but the VM renders using aqua as far as I know, and therefore should display buttons, sliders, text and any other Swing control with the retina quality.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .