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

message showing I/O exceptions with resource bundles in a jar

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.4
    • tools
    • jar
    • x86
    • windows_nt



      Name: rm29839 Date: 11/25/97


      When loading bundles, via Resource.getBundle(), in an applet where the
      applet class and bundles are stored in a jar file, I/O exceptions are
      thrown for the locale specific bundles that don't exist. The exceptions
      don't occur when the applet class and bundles are not in a jar file.

      Here's a simple example:



        // file test2\Main.java

        package test2;

        import java.lang.System;
        import java.util.ResourceBundle;

        public class Main extends java.applet.Applet
        {

          public void init()
          {

             ResourceBundle b = ResourceBundle.getBundle("test2.res.bund1");
             System.out.println("test2 output: " + b.getString("winky"));

          }

        }


        // file test2\res\bund1.java

        package test2.res;

        import java.util.*;

        public class bund1 extends ListResourceBundle
        {

          public Object[][] getContents()
          {
            return contents;
          }

          static final Object[][] contents =
          {
            {"winky", "Winky was here"}
          };

        }


      When test2 is run as an applet without being stored in a jar the following
      output is created:

      % appletviewer test2NoJar.html
      test2 output: Winky was here

      The same test2, but the class and the bundle are stored in a jar, creates
      the following output:

      % appletviewer test2Jar.html
      I/O exception when loading: test2.res.bund1_en_US
      I/O exception when loading: test2.res.bund1_en
      I/O exception when loading: test2.res.bund1_en_US
      I/O exception when loading: test2.res.bund1_en
      test2 output: Winky was here
      (Review ID: 20633)
      ======================================================================

            zlisunw Zhenghua Li (Inactive)
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: