Java 8 RFR 8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X

David Holmes david.holmes at oracle.com
Mon Jul 29 05:13:38 UTC 2013


On 27/07/2013 3:53 AM, Brent Christian wrote:
> Please review my fix for 8011194 : "Apps launched via double-clicked
> .jars have file.encoding value of US-ASCII on Mac OS X"
>
> http://bugs.sun.com/view_bug.do?bug_id=8011194
>
> In most cases of launching a Java app on Mac (from the cmdline, or from
> a native .app bundle), reading and displaying UTF-8 characters beyond
> the standard ASCII range works fine.
>
> A notable exception is the launching of an app by double-clicking a .jar
> file.  In this case, file.encoding defaults to US-ASCII, and characters
> outside of the ASCII range show up as garbage.

Why does this occur? What sets the encoding to US-ASCII?

David
-----

> (FWIW, this is not recommended by Apple as a method for deploying Java
> apps [1], though OS X does have a Jar Launcher.app to make it work.)
>
> It's worth mentioning that this is not something that has ever worked on
> MacOS X. (Apple's JRE defaulted to "MacRoman" for English and AFAIK most
> European locales.  I believe this is a holdover from the pre-OS X days).
>
> Even so, the situation can be improved.  When launching, if the standard
> encoding comes up as  US-ASCII, but there are no hints from the
> environment (e.g. LANG/etc environment variables), it would be sane to
> instead use UTF-8 as the default encoding on MacOS X.  An explicit
> file.encoding setting by the user is still honored (and can even be set
> back to US-ASCII).
>
> I believe this also fixes the related issue with webstart [2].
>
> Webrev is here:
> http://cr.openjdk.java.net/~bchristi/8011194/webrev.00/
>
> Thanks,
> -Brent
>
> [1]
> http://developer.apple.com/library/mac/#documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.html
>
> [2] http://bugs.sun.com/view_bug.do?bug_id=8011195
>



More information about the core-libs-dev mailing list