Can't find the problem with some code, but it won't run.

I've gone over this a few times. Processing is reporting "Found one too many { characters without a } to match it." I count exactly twenty "{" and the same number of "}". Help?

EDIT: I put all my classes in different tabs. This is the tab Processing opened when I got the error.

public class Server { private JSONObject data; private String name; private String status; private int port; private boolean shared; private String publicURL; public Server(String newName) { name = newName; refreshData(); } //Getting---------------------- public String getName() { return name; } public String getStatus() { return status; } public String getPublicUrl() { return publicURL; } public String toString() { return data.toString(); } //Misc------------------------- public void refreshData() { JSONArray servers = null; try { servers = loadJSONArray("http://127.0.0.1:33649/server/list"); } catch (Exception e1) { launch("C:\\ProgramData\\Fenix\\Fenix.exe"); while (servers==null) { try { servers = loadJSONArray("http://127.0.0.1:33649/server/list"); } catch (Exception e2) { } } } for (int i = 0; i<servers.size(); i++) { JSONObject temp = servers.getJSONObject(i); if (temp.getString("name").equals(name)) { data = temp; } } if (data.getBoolean("starting")) { status = "Starting"; } else if (data.getBoolean("stopping")) { status = "Stopping"; } else if (data.getBoolean("running")) { status = "Running"; } else { status = "Stopped"; } port = data.getInt("port"); if (data.getBoolean("shared")) { shared = true; publicURL = data.getString("publicUrl"); } else { shared = false; publicURL = null; } } }

Answers

  • The problem isn't always where it's reported to be - unbalanced braces on earlier code is probably causing this.

  • edited April 2016

    rejected answer 8(

    but no new information for us...

    the problem is in a different tab - processing just concatenates all the code together before it runs it.

    don't believe me?

    TAB 1

    void setup() {
    }
    
    void error_here() {
        // no closing bracket
    

    TAB 2

    void ok() {
        // this is perfectly valid
    }
    

    run this and it'll tell you the error is in TAB2.

Sign In or Register to comment.