Discussion in 'Spigot Plugin Development' started by Arjan, Jan 16, 2016.

  1. Hello,

    After upgrading to windows 10 and downgrading back to windows 8.1 I experienced some issues with my Java installations. I've managed to get it back working, meaning that I can run local servers again and compile plugins using eclipse. However, I keep getting a strange error which I am not sure if it is because my Java is screwed up or because my coding is even worse. (Ignore the String raw for now)

    This is the error:
    Code (Text):
    java.lang.NoSuchMethodError: com.arjanforgames.Data.Database.getJson(Ljava/lang/
    This is the getJson function:
    Code (Text):
    public static JsonObject getJson(String raw){
    String sURL = "http://*private*.com/server/info.php";

    URL url = new URL(sURL);
    HttpURLConnection request = (HttpURLConnection) url.openConnection();
    JsonParser jp = new JsonParser();
    JsonElement root = jp.parse(new InputStreamReader((InputStream) request.getContent()));
    JsonObject rootobj = root.getAsJsonObject();
    return rootobj;
    }catch(Exception e){
    return null;
    And I'm calling it in the onEnable function like this:
    Code (Text):
    I'm compiling with JRE System Library [JavaSE-1.8] and the server is also running on Java 1.8

  2. Hi, check your build path. It seems that the Google Gson library is missing.

    Or maybe you mistyped your import: "Lcom/google/gson/JsonObject;"
  3. @ImAFlyingPancake
    In most cases, the gson library is included within craftbukkit/spigot. And the L<class>; is how java class references are compiled, e.g:
    Z for boolean
    C for char
    B for byte
    I for int
    And then L for a class.
    @Arjan are the Database class and the class you call the method from in the same project?
  4. Nope, that's not the case.

    They are in the same project but a different package.
  5. @Arjan hrm, strange. I did a bit of googling and stumbled on this:
    "If the exception appears when calling a method on objects instantiated by classes youmade, then your build process seems to be faulty. Make sure the class files that you are actually running are updated when you compile."
    Perhaps there is some sort of error somewhere or you need to resave the Database class by simply editing something in it and then undoing