Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8043977

Default encoding error when executing a jar file from the finder/desktop.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 7u55
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.7.0_55"
      Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin Mac-mini-de-Oscar.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      The following example works fine if you execute it from command line, but if you create a jar and you execute the jar making double click it in the finder/desktop, you will see '?' chars instead of acuted vocals and n tilde.

      This provokes different behaviour between developer execution (command line) and production execution (icon/app double click) in Mac OS X.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the example:

          javac DefaultEncoding.java

      Create a jar file:

          jar cvfe DefaultEncoding.jar DefaultEncoding DefaultEncoding.class

      Execute the jar file making double click it in the finder/desktop.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Message dialog showing in the last line: á é í ó ú ñ


      ACTUAL -
      Message dialog showing in the last line: ? ? ? ? ? ?


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      import javax.swing.*;

      public class DefaultEncoding
      {
          public static void main(String args[]) throws Exception
          {
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              PrintStream p = new PrintStream(baos);
              p.println("'aeiou' acutes and 'n' tilde:");
              p.println("\u00e1 \u00e9 \u00ed \u00f3 \u00fa \u00f1");
              p.close();
              JOptionPane.showMessageDialog(null, baos.toString());
              System.exit(0);
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      You can specify a encoding in all cases, but you must catch UnsupportedEncodingException. This should be unnecessary.

            igerasim Ivan Gerasimov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: