Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
add comment

6 Answers 6

up vote 2 down vote accepted

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.

share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

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, log out or make a copy of the app so that OSX will notice the change. Now, the info window will not show "Open in Low Resolution" as checked. Launch Eclipse and enjoy your new retina awesomeness.

share|improve this answer
    
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
add comment

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

share|improve this answer
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
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.