JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6398

java.lang.NullPointerException when executing jruby.exe under Windows 7 (v1.6.6)

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: JRuby 1.6.7
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Hello

      I have problem using 1.6.6 release on Windows 7.
      I downloaded jruby-bin-1.6.6.zip, unzipped it and ran it.

      Here is the output:

      D:\>d:\jruby-1.6.6\bin\jruby -S gem list
      EncodingService.java:45:in `<init>': java.lang.NullPointerException
      from Ruby.java:1180:in `initCore'
      from Ruby.java:1113:in `bootstrap'
      from Ruby.java:1085:in `init'
      from Ruby.java:182:in `newInstance'
      from Main.java:240:in `internalRun'
      from Main.java:222:in `run'
      from Main.java:206:in `run'
      from Main.java:186:in `main'

      D:\>d:\jruby-1.6.6\bin\jruby -v
      jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) Client VM 1.6.0_24) [Windows 7-x86-java]
      EncodingService.java:45:in `<init>': java.lang.NullPointerException
      from Ruby.java:1180:in `initCore'
      from Ruby.java:1113:in `bootstrap'
      from Ruby.java:1085:in `init'
      from Ruby.java:182:in `newInstance'
      from Main.java:240:in `internalRun'
      from Main.java:222:in `run'
      from Main.java:206:in `run'
      from Main.java:186:in `main'

      Best Regards

      David Huang

        Activity

        Hide
        Hiro Asari added a comment -

        I suspect this is an encoding issue. (I am not sure how to get around it at the moment.)

        C:\Users\asari\Development\src\jruby>.\bin\jruby -v -S gem list
        jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [Windows 7-amd64-java]
        
        *** LOCAL GEMS ***
        
        sources (0.0.1)
        
        Show
        Hiro Asari added a comment - I suspect this is an encoding issue. (I am not sure how to get around it at the moment.) C:\Users\asari\Development\src\jruby>.\bin\jruby -v -S gem list jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [Windows 7-amd64-java] *** LOCAL GEMS *** sources (0.0.1)
        Show
        Hiro Asari added a comment - https://github.com/jruby/jruby/blob/56735729b1f89501726af1fbc4ce2a8dd223ba77/src/org/jruby/runtime/encoding/EncodingService.java#L45 How can this line throw a NPE?
        Hide
        Leonardo Wong added a comment -

        I have the same problem. I am using Traditional Chinese Windows Vista Business SP2. I tried re-install java but doesn't help.

        C:\Users\Leonardo>jruby -v
        jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) Client VM 1
        .6.0_30) [Windows Vista-x86-java]
        EncodingService.java:45:in `<init>': java.lang.NullPointerException
                from Ruby.java:1180:in `initCore'
                from Ruby.java:1113:in `bootstrap'
                from Ruby.java:1085:in `init'
                from Ruby.java:182:in `newInstance'
                from Main.java:240:in `internalRun'
                from Main.java:222:in `run'
                from Main.java:206:in `run'
                from Main.java:186:in `main'
        
        C:\Users\Leonardo>java -version
        java version "1.6.0_30"
        Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
        Java HotSpot(TM) Client VM (build 20.5-b03, mixed mode, sharing)
        
        Show
        Leonardo Wong added a comment - I have the same problem. I am using Traditional Chinese Windows Vista Business SP2. I tried re-install java but doesn't help. C:\Users\Leonardo>jruby -v jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) Client VM 1 .6.0_30) [Windows Vista-x86-java] EncodingService.java:45:in `<init>': java.lang.NullPointerException from Ruby.java:1180:in `initCore' from Ruby.java:1113:in `bootstrap' from Ruby.java:1085:in `init' from Ruby.java:182:in `newInstance' from Main.java:240:in `internalRun' from Main.java:222:in `run' from Main.java:206:in `run' from Main.java:186:in `main' C:\Users\Leonardo>java -version java version "1.6.0_30" Java(TM) SE Runtime Environment (build 1.6.0_30-b12) Java HotSpot(TM) Client VM (build 20.5-b03, mixed mode, sharing)
        Hide
        Hiro Asari added a comment -

        Does passing -U to JRuby help?

        jruby -U -v
        
        Show
        Hiro Asari added a comment - Does passing -U to JRuby help? jruby -U -v
        Hide
        Leonardo Wong added a comment -

        no...

         C:\Users\Leonardo>jruby -U -v
        jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) Client VM
        .6.0_30) [Windows Vista-x86-java]
        EncodingService.java:45:in `<init>': java.lang.NullPointerException
                from Ruby.java:1180:in `initCore'
                from Ruby.java:1113:in `bootstrap'
                from Ruby.java:1085:in `init'
                from Ruby.java:182:in `newInstance'
                from Main.java:240:in `internalRun'
                from Main.java:222:in `run'
                from Main.java:206:in `run'
                from Main.java:186:in `main'
        Show
        Leonardo Wong added a comment - no... C:\Users\Leonardo>jruby -U -v jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) Client VM .6.0_30) [Windows Vista-x86-java] EncodingService.java:45:in `<init>': java.lang.NullPointerException from Ruby.java:1180:in `initCore' from Ruby.java:1113:in `bootstrap' from Ruby.java:1085:in `init' from Ruby.java:182:in `newInstance' from Main.java:240:in `internalRun' from Main.java:222:in `run' from Main.java:206:in `run' from Main.java:186:in `main'
        Hide
        David Huang added a comment -

        Hello

        I am using Traditional Chinese version Windows as well but I am using Windows 7.

        David

        Show
        David Huang added a comment - Hello I am using Traditional Chinese version Windows as well but I am using Windows 7. David
        Hide
        Leonardo Wong added a comment -

        I tried on my netbook, running Traditional Chinese WinXP SP 3, same problem...

        Show
        Leonardo Wong added a comment - I tried on my netbook, running Traditional Chinese WinXP SP 3, same problem...
        Hide
        Leonardo Wong added a comment - - edited

        I just tried on my office computer, using ENGLISH Windows Vista Home Basic, fail too...

        C:\Users\Leonardo Wong>jruby -v
        jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) Client VM 1
        .6.0_29) [Windows Vista-x86-java]
        EncodingService.java:45:in `<init>': java.lang.NullPointerException
                from Ruby.java:1180:in `initCore'
                from Ruby.java:1113:in `bootstrap'
                from Ruby.java:1085:in `init'
                from Ruby.java:182:in `newInstance'
                from Main.java:240:in `internalRun'
                from Main.java:222:in `run'
                from Main.java:206:in `run'
                from Main.java:186:in `main'
        Show
        Leonardo Wong added a comment - - edited I just tried on my office computer, using ENGLISH Windows Vista Home Basic, fail too... C:\Users\Leonardo Wong>jruby -v jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) Client VM 1 .6.0_29) [Windows Vista-x86-java] EncodingService.java:45:in `<init>': java.lang.NullPointerException from Ruby.java:1180:in `initCore' from Ruby.java:1113:in `bootstrap' from Ruby.java:1085:in `init' from Ruby.java:182:in `newInstance' from Main.java:240:in `internalRun' from Main.java:222:in `run' from Main.java:206:in `run' from Main.java:186:in `main'
        Hide
        Leonardo Wong added a comment -

        Just tried on another PC at office. Running ENGLISH Windows 7 Home Premium, same error.

        Show
        Leonardo Wong added a comment - Just tried on another PC at office. Running ENGLISH Windows 7 Home Premium, same error.
        Hide
        Hiro Asari added a comment - - edited

        I'm guessing that we just don't know about the encoding that your OS is using, and fail to get the encoding you need.

        Do you have JDK? If so, can you compile this simple program, run it, and report the result?

        JRuby6398Test.java
        import java.nio.charset.Charset;
        
        public class JRuby6398Test {
        
            /**
             * @param args the command line arguments
             */
            public static void main(String[] args) {
                Charset def = Charset.defaultCharset();
                System.out.println(def.name());
            }
        }
        
        Show
        Hiro Asari added a comment - - edited I'm guessing that we just don't know about the encoding that your OS is using, and fail to get the encoding you need. Do you have JDK? If so, can you compile this simple program, run it, and report the result? JRuby6398Test.java import java.nio.charset.Charset; public class JRuby6398Test { /** * @param args the command line arguments */ public static void main( String [] args) { Charset def = Charset.defaultCharset(); System .out.println(def.name()); } }
        Hide
        Leonardo Wong added a comment -

        I don't know Java >.<, I follow these:
        http://www.oracle.com/technetwork/java/compile-136656.html
        http://www.tech-recipes.com/rx/826/java-exception-in-thread-main-javalangnoclassdeffounderror/

        The result is:

        C:\Program Files\Java\jdk1.6.0_30\bin>javac c:\JRuby6398Test.java
        
        C:\Program Files\Java\jdk1.6.0_30\bin>java -classpath c:\ JRuby6398Test
        x-MS950-HKSCS
        Show
        Leonardo Wong added a comment - I don't know Java >.<, I follow these: http://www.oracle.com/technetwork/java/compile-136656.html http://www.tech-recipes.com/rx/826/java-exception-in-thread-main-javalangnoclassdeffounderror/ The result is: C:\Program Files\Java\jdk1.6.0_30\bin>javac c:\JRuby6398Test.java C:\Program Files\Java\jdk1.6.0_30\bin>java -classpath c:\ JRuby6398Test x-MS950-HKSCS
        Hide
        Leonardo Wong added a comment - - edited

        Traditional Chinese Windows Vista Business SP2
        English Windows Vista Home Basic

        x-MS950-HKSCS

        English Windows 7 Home Premium

        x-windows-950

        All 3 computers get NPE error

        Show
        Leonardo Wong added a comment - - edited Traditional Chinese Windows Vista Business SP2 English Windows Vista Home Basic x-MS950-HKSCS English Windows 7 Home Premium x-windows-950 All 3 computers get NPE error
        Hide
        Hiro Asari added a comment -

        Leonardo,

        Thank you very much for your efforts. Indeed, we do not know anything about the indicated encodings, and we end up throwing NPE. This part of the logic is new in 1.6.6.

        It seems to me that, instead of trying to account for all possible values of Charset.defaultCharset(), if we don't know anything about the supplied encoding, we should fall back to something. "ASCII-8BIT" seems to be a reasonable choice in this context.

        So, I pushed this fix to the 1.6 branch (16721e9) and the master (bbf21f2).

        This will be available tomorrow morning at http://ci.jruby.org/snapshots/release/ and http://ci.jruby.org/snapshots/master/, respectively. Please test it, and let us know if it solves the problem.

        Show
        Hiro Asari added a comment - Leonardo, Thank you very much for your efforts. Indeed, we do not know anything about the indicated encodings, and we end up throwing NPE. This part of the logic is new in 1.6.6. It seems to me that, instead of trying to account for all possible values of Charset.defaultCharset() , if we don't know anything about the supplied encoding, we should fall back to something. "ASCII-8BIT" seems to be a reasonable choice in this context. So, I pushed this fix to the 1.6 branch (16721e9) and the master (bbf21f2). This will be available tomorrow morning at http://ci.jruby.org/snapshots/release/ and http://ci.jruby.org/snapshots/master/ , respectively. Please test it, and let us know if it solves the problem.
        Hide
        Leonardo Wong added a comment -

        Coz Windows here, is that I download
        http://ci.jruby.org/snapshots/release/jruby-bin-1.6.7.dev.zip
        and replace the folder C:\jruby-1.6.6\bin ?

        Show
        Leonardo Wong added a comment - Coz Windows here, is that I download http://ci.jruby.org/snapshots/release/jruby-bin-1.6.7.dev.zip and replace the folder C:\jruby-1.6.6\bin ?
        Hide
        Hiro Asari added a comment -

        Leonardo,

        That file will expand to "jruby-1.6.7.dev". You can put it anywhere on your disk (best if the path didn't have any white space), and add "jruby-1.6.7.dev\bin" to your %PATH% (before C:\jruby-1.6.6\bin, so the correct "jruby" is invoked).

        There is no need to tinker with your existing installation (though it doesn't work for you, so it might not be worth keeping it).

        Show
        Hiro Asari added a comment - Leonardo, That file will expand to "jruby-1.6.7.dev". You can put it anywhere on your disk (best if the path didn't have any white space), and add "jruby-1.6.7.dev\bin" to your %PATH% (before C:\jruby-1.6.6\bin, so the correct "jruby" is invoked). There is no need to tinker with your existing installation (though it doesn't work for you, so it might not be worth keeping it).
        Hide
        David Huang added a comment - - edited

        Hello Hiro

        YES! JRuby-1.6.7.dev(2012-02-06 32028b6) has solved the problem.

        Thanks for help

        When will v1.6.7 be released?

        Show
        David Huang added a comment - - edited Hello Hiro YES! JRuby-1.6.7.dev(2012-02-06 32028b6) has solved the problem. Thanks for help When will v1.6.7 be released?
        Hide
        Hiro Asari added a comment -

        JRuby 1.6.7 should be out some time soon.

        Show
        Hiro Asari added a comment - JRuby 1.6.7 should be out some time soon.
        Hide
        ryenus added a comment -

        Hiro,

        Looks like this bug is different from JRUBY-6267.

        Actually I'm not able to reproduce this bug on either jruby-1.6.6 or jruby-1.6.7.dev

        Show
        ryenus added a comment - Hiro, Looks like this bug is different from JRUBY-6267 . Actually I'm not able to reproduce this bug on either jruby-1.6.6 or jruby-1.6.7.dev
        Hide
        Leonardo Wong added a comment -

        jruby-bin-1.6.7.dev.zip (07-Feb-2012 12:17)
        md5: d57855b6bb352192e97fa31b98347eb7

        it works. thx!

        Show
        Leonardo Wong added a comment - jruby-bin-1.6.7.dev.zip (07-Feb-2012 12:17) md5: d57855b6bb352192e97fa31b98347eb7 it works. thx!
        Hide
        Hiro Asari added a comment -

        ryenus,

        Thank you for checking. I think I came close when I figured out that this ticket and JRUBY-6267 share one characteristic: an unusual default Charset for the JVM. While this one is unknown, yours is a known default Charset with a bug.

        Show
        Hiro Asari added a comment - ryenus, Thank you for checking. I think I came close when I figured out that this ticket and JRUBY-6267 share one characteristic: an unusual default Charset for the JVM. While this one is unknown, yours is a known default Charset with a bug.
        Hide
        ryenus added a comment -

        Hiro,

        welcome, but I think the ideal solution should be simply wrapping all encodings supported on JVM (or use them directly), instead of re-implementing it (or some better wording here)

        see http://docs.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html

        Show
        ryenus added a comment - Hiro, welcome, but I think the ideal solution should be simply wrapping all encodings supported on JVM (or use them directly), instead of re-implementing it (or some better wording here) see http://docs.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html

          People

          • Assignee:
            Hiro Asari
            Reporter:
            David Huang
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: