Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold

syhler

Registered
  • Content Count

    3
  • Joined

  • Last visited

  • Feedback

    0%

Everything posted by syhler

  1. Thank you very much What is the reason for java.lang.reflect isn't supported?
  2. What is a reflection? and how do I use it? Edited After some research I think I understand what reflection is, it is some kind of library right? If so, do you know another JSON library which doesn't use reflection? or am I forced to create my own?
  3. I'm trying to add a JSON library by adding every java file from https://github.com/stleary/JSON-java to my project. But it keeps giving me the error java.lang.NoClassDefFoundError: scripts/JSONObject Which makes sense because it fails to load the JSONObject. But why? Error Loading Local Script: JSONObject! I have tried to make a package inside the scripts package called "org.json" without any luck, I have also tried to put the files directly into scripts package.(Check picture for reference) I don't think the run method has anything to do with it, but it looks like this @Override public void run() { println("Hey Test"); JSONObject json = null; try { json = JsonParser.readJsonFromUrl("url"); } catch (IOException e) { e.printStackTrace(); } assert json != null; println(json.toString()); } JsonParser.readJsonFromUrl Comes from a class which is taken from StackOverflow - https://stackoverflow.com/questions/4308554/simplest-way-to-read-json-from-a-url-in-java- And looks something like that public class JsonParser{ private static String readAll(Reader rd) throws IOException { StringBuilder sb = new StringBuilder(); int cp; while ((cp = rd.read()) != -1) { sb.append((char) cp); } return sb.toString(); } public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException { InputStream is = new URL(url).openStream(); try { BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); String jsonText = readAll(rd); JSONObject json = new JSONObject(jsonText); return json; } finally { is.close(); } } } Yes, I do have VIP (at least for 2 days) and I'm using IntelliJ Idea. To set my project up I have used the guide from here. Thank you for your time
×
×
  • Create New...