Search code examples
javajarexecutable-jarnosuchmethoderror

Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Character.isAlphabetic(I)Z


I'm trying to run a .jar that runs fine on my own computer but gives the following exception on someone else's.

Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Character.isAlphabetic(I)Z
    at chatai.Word.shrinkEndPunct(Word.java:91)
    at chatai.Word.createWord(Word.java:36)
    at chatai.ChatAI.addSentence(ChatAI.java:54)
    at shared.Initializer.main(Initializer.java:130)

I have never seen the (I)Z part before, does anyone know what this means? I already tried updating Java.


Solution

  • I have never seen the (I)Z part before, does anyone know what this means?

    The (I)Z part describes the argument and return type part of the method signature.

    In this case it says that the method takes as argument an int, and returns a boolean.

    Here's the complete list of such type notation:

    V           void
    Z           boolean
    C           char
    B           byte
    S           short
    I           int
    F           float
    J           long
    D           double
    
    L<class>;   Reference type, for example Ljava/lang/String;
    

    It's hard to tell why the program runs fine on your computer. There is no method called isAlphabetic in the standard Java API.

    The Character.isAlphabetic method was introduced in Java 7. It seems like you're running Java 7, and your friend has only Java 6 (or some lower version) installed.