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

Sell OSRS Gold
syhler

NoClassDefFoundError: trying to add an lib

Recommended Posts

 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)

image.png.a3ba97ca81a4bae75664eee629d89956.png

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 :) 

 

Share this post


Link to post
Share on other sites
Array
19 minutes ago, Naton said:

You cannot use reflection

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?

Edited by syhler

Share this post


Link to post
Share on other sites
16 minutes ago, syhler said:

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?

Essentially you can't use anything from java.lang.reflect

I don't use JSON but there is a JSON library included in dax walker. https://github.com/itsdax/Runescape-Web-Walker-Engine/tree/master/dax_api/api_lib/json

  • Thanks 1

Share this post


Link to post
Share on other sites
15 minutes ago, syhler said:

What is the reason for java.lang.reflect isn't supported? 

Java is already one of the worst languages when it comes to security, and allowing reflection can only make the matters worse.

 

48 minutes ago, syhler said:

After some research I think I understand what reflection is, it is some kind of library right?

Not exactly. Reflection is one of the language's features, which can be used through the reflection API.

You can learn more here: https://docs.oracle.com/javase/tutorial/reflect/index.html

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Similar Content

    • By ELON
      ELON AIO COMBAT
      abc2 lvl 8
      + Custom antiban
      gui support
      save/load
      SOURCE:https://github.com/Elon333/ELON-Combat-Aio
      LINK TO SCRIPT: https://tribot.org/repository/script/id/3411
       

      Bug Report info:
      bot debug copy paste in pastebin
      client debug copy paste in pastebin
      explanation on bug
      screenshot/video if applicable
      MY DISCORD INFO: Elon#6697
      message my discord for faster reply

      ELON FREE SCRIPTS:
      RESTLESS GHOST: https://tribot.org/repository/script/id/3416
      PRIEST IN PERIL: https://tribot.org/repository/script/id/3407
      COMBAT AIO: https://tribot.org/repository/script/id/3411
       
    • By whyareyoudoingthis
      Hello, I would really appreciate some advice since it's lookin kinda hopeless.
      I'm getting consistent bans on p2p accounts with nFletcher, within 24-48 hours, even though I am botting with randomized breaks, doing some manual selling/restocking every 1-2 hours. I did not bot during the night, maybe 3 sessions for 3-4 hours per day TOPS.
      I even did some slayer in between every 1-2 hours on my semi-main and it just got banned for 2 days regardless (ty god no perma, obviously not gonna bot on a valuable account ever again, that was dumdum)
      Am I doing something wrong or what? This seems completely unprofitable and unsustainable. I am not into this as much as to create a bot farm, but I wanted to do a total of 10ish m/day on 1-2 accounts and this seems impossible. 
      Any advice? Thank you so much in advance
    • By DizFunk
      Hi guys, I just started attempting to script. I bought VIP so I could write my own scripts. I've been having the hardest time setting up my eclipse to work with TRIBot. So far I have set up my eclipse to compile with JDK/JRE 8, TRIBot is being launched with JDK 8. Everything seems to be setup correctly, however I get this odd error message in my bot debug logs. I've attached a photo of the logs. 
      Here is what my class file looks like: 
      package scripts;
      import org.tribot.script.Script;
      import org.tribot.script.ScriptManifest;
      @ScriptManifest (authors = { "DizFunk" }, category = "Test", name = "Test")
      public class Test extends Script {
          @Override
          public void run() {
              println("Hello World!1");
          }
      }
       If anyone knows whats going on here it would be a big help

    • By will6100
      I really love the process of developing a script, testing it, debugging it, etc.. So after writing my first really simple script that would tan hides, I got my first botting account banned, which is something I knew was gonna happen since my lack of scripting knowledge. Im ready to get a new one up and going and continue to develop more basic scripts to sharpen my scripting skills. Im sharing my first script here and looking to hear what I should do and should not do. Also get some tips on what to look for to reduce the banning rates of my testing accounts. The account I was using was only combat lvl 5 and didnt have any quests done, I guess that didnt help too? I was also about to introduce ABC2 into the script and learn how to use it but my account got banned right before I could implement it. So looking forward to hear your criticisms about my script and tips to not get the script bannable. Also have in mind I didnt really refactor anything, some parts may look ugly, beware!
      package scripts; import org.tribot.api.DynamicClicking; import org.tribot.api.General; import org.tribot.api.Timing; import org.tribot.api.input.Mouse; import org.tribot.api2007.*; import org.tribot.api2007.types.RSNPC; import org.tribot.api2007.types.RSObject; import org.tribot.api2007.types.RSTile; import org.tribot.api2007.util.ThreadSettings; import org.tribot.script.Script; import org.tribot.script.ScriptManifest; import java.awt.*; import java.util.function.BooleanSupplier; @ScriptManifest(category = "Moneymaking", authors = "will6100" , name = "Tanner") public class Tanner extends Script { private final static int BLACK_DHIDE_ID = 1747; private final static int TANNED_LEATHER_ID = 2509; private final static int ELLIS_ID = 3231; private final static int BANK_BOOTH_ID = 10355; private final static int COINS_ID = 995; private boolean isBankable() { RSObject[] booths = Objects.findNearest(100, BANK_BOOTH_ID); if (booths.length > 1) { return booths[0].isOnScreen(); } return false; } private boolean coinsCheck() { if (Inventory.find(COINS_ID).length < 1) { if (Banking.find(COINS_ID).length > 0) { if (!Inventory.isFull()) { return Banking.withdraw(0, COINS_ID); } else { if (Inventory.find(BLACK_DHIDE_ID).length > 0) { return Banking.deposit(1, BLACK_DHIDE_ID); } else if (Inventory.find(TANNED_LEATHER_ID).length > 0){ return Banking.depositAll() > 0; } } } } else { return true; } return false; } private boolean bank() { if (!openBank()) { General.println("Couldnt open bank"); return false; } if (!coinsCheck()) { General.println("No more gold"); return false; } if (!setupInventory()) { General.println("No more hides"); return false; } sleep(100,1000); return true; } private boolean setupInventory() { if (Inventory.find(TANNED_LEATHER_ID).length > 0) { sleep(50,1000); if (Banking.deposit(0,TANNED_LEATHER_ID)) { if (Banking.find(BLACK_DHIDE_ID).length > 0){ sleep(50,1000); Banking.withdraw(0, BLACK_DHIDE_ID); return Timing.waitCondition(this::readyToTan, General.random(3000,5000)); } } } else if (Inventory.find(TANNED_LEATHER_ID).length < 1) { sleep(50,1000); if (Banking.find(BLACK_DHIDE_ID).length > 0){ Banking.withdraw(0, BLACK_DHIDE_ID); return Timing.waitCondition(this::readyToTan, General.random(3000,5000)); } } return false; } private boolean openBank() { if (!Banking.isBankScreenOpen()) { if (!isBankable()){ if(!walkToDestCondition(this::isBankable)) { return false; } } return clickBankBooth(); } return true; } private boolean clickBankBooth() { RSObject[] bankBooths = Objects.findNearest(40, BANK_BOOTH_ID); RSObject booth; if(bankBooths.length > 1) { do { sleep(50); booth = bankBooths[General.random(0, bankBooths.length - 2)]; } while (!booth.isOnScreen() && !booth.isClickable()); booth.hover(); if (isHoverRendered(Mouse.getPos())){ Mouse.click(1); }else { clickBankBooth(); } return Timing.waitCondition(Banking::isBankScreenOpen, General.random(25000,27000)); } return false; } private boolean isHoverRendered (Point toHover) { return !Screen.getColorAt(Mouse.getPos()).equals(new Color(0, 0, 0)); } private boolean isTannable() { RSNPC[] ellis = NPCs.find(ELLIS_ID); if (ellis.length < 1) { return false; } else if (isTanningWindowOpen()){ return true; } return ellis[0].isOnScreen(); } private boolean tanLeather() { RSNPC ellis; if (isTannable()) { sleep(100,200); ellis = NPCs.find(ELLIS_ID)[0]; while (!isTanningWindowOpen()) { Mouse.setSpeed(190); sleep(300,500); if (DynamicClicking.clickRSNPC(ellis,"Trade " + ellis.getName())){ Mouse.setSpeed(115); Timing.waitCondition(this::isTanningWindowOpen, General.random(15000, 17000)); sleep(200,500); Interfaces.get(324,107).click("Tan all"); return Timing.waitCondition(() -> !isTanningWindowOpen(), General.random(3000,5000)); } } } else { return walkToDestCondition(this::isTannable); } return false; } private boolean walkToDestCondition(BooleanSupplier waitCondition) { Walking.blindWalkTo(new RSTile(3278 + General.random(-2,2), 3180 + General.random(-1, 1))); return Timing.waitCondition(waitCondition, General.random(11000,12000)); } private boolean isTanningWindowOpen() { return Interfaces.isInterfaceValid(324); } private boolean readyToTan() { return Inventory.find(BLACK_DHIDE_ID).length > 0 && Inventory.find(COINS_ID).length > 0 ; } @Override public void run() { Mouse.setSpeed(115); ThreadSettings ts = new ThreadSettings(); ts.setClickingAPIUseDynamic(true); while (true) { sleep(50); if (isTannable()) { if (readyToTan()) { if(!tanLeather()){ General.println("1"); break; } } else { if(!bank()) { General.println("2"); break; } } } else if (isBankable()) { if (readyToTan()) { if(!tanLeather()){ General.println("3"); break; } } else { if(!bank()) { General.println("4"); break; } } } else if (readyToTan()) { if(!tanLeather()){ General.println("5"); break; } } else { if(!bank()) { General.println("6"); break; } } } } }  
    • By schenkelenkel
      Getting this error, client won't start.

    • By ilysmd
      Looking to buy a cox scouting bot, that will keep scouting until it finds a raid within the desired parameters.
    • By ltztakechi
      I try to open the bot and it says no java runtime present requesting install, I have installed javas last update about 4 times restarted my computer and my browsers and still same error. someone pls help.

    • By idkfa
      Hello my knowledgeable friends,
      Ive botted about 3 accounts to max combat and ran small gold farms but lately I really interested in learning how to script myself so I can give back to the awesome community and start goldfarming on a professional level. That being said ive got some questions.Little background check, im a total noob when in comes to programming languages.
      - ive read that learning Java is a must. But what I don't understand is do I need to learn everything about java or just parts that are relevant to scripting for Tribot. Do I have to take a course or to do a deep dive like enlisting in an education  or is learning Java just for Tribot enough?
      - If a book is preferable, do you have any recognmendations?
      - after being proficiant in Java ive read I still need to learn how to script for Tribot specifically. Is this a long process?
      - I know this is a difficult question to answer but how long do you guys recon this process will take in hours learning Java and scripting for Tribot? Ive got about 2/3 hours to spare a day and about 5/7 on weekends
      - Also is there a discord with like minded people out there looking to learn java/tribot and also one for goldfarmer (not gonna ask for methods lol)
       
      Sorry for the long and nooby questions. Hope you guys can point me in the right direction. 
      Any constructive comments are greatly appriciated.
      Cheers,
      IDKFA
    • By Fluffee
      Fluffee's Server Setup 3.0
      As some of you may know, I released an automated server setup script a little over a year ago. Albeit that script worked well, I was never fully satisfied with it, as I found it to be kind of messy to use. As a result, I rewrote the script, and restructured it, to add more, and stronger support for the different versions of Debian, the different versions of CentOS and the different versions of Ubuntu. However, with so many different Operating Systems being supported, and many different server providers having different setups, it's hard for me to test every possible scenario on my own. Which is why I've been privately handing this script out, and am now publicly looking for help.

      What does the script do?
      Similar to my previous setup script, this script changes the SSH port and creates a new user for connecting and using the server and disables root SSH connections; it installs the latest version of TightVNC Server (1.3.10) and sets that up with the desired port and password. It installs JDK 102 (32 or 64 bit depending on the OS), and installs TRiBot and OSBuddy and sets up the appropriate .jar file associations.
      What operating systems does it support?
      - CentOS (6.x and 7.x) (32 and 64 bit)
      - Debian (7.x and 8.x) (32 and 64 bit)
      - Ubuntu (12.x, 14.x and 16.x) (32 and 64 bit)
      Does it work?
      As far as I know, yes it does in fact work, and it works well if I might add. However, given that I can't test every possible setup, there is the potential for differences and issues
      How do I run the script?
      Login as root to a fresh VPS/dedi running one of the supported operating systems. From there run the commands listed below and follow the onscreen instructions. For those who would like to see the script's code, it can be found on my bitbucket here. The commands to run are as follows:
      wget --no-check-cert https://bitbucket.org/teamfluffee/fluffees-server-setup/raw/add-shared-functions/fluffees-server-setup.sh && chmod +x fluffees-server-setup.sh && bash fluffees-server-setup.sh -v Version History
       
  • Our picks

    • Come give us feedback on the next version of TRiBot!
        • Thanks
        • Like
      • 30 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
        • Like
      • 19 replies
    • Over the last three weeks, I've been working on upgrading our server infrastructure. It's finally ready and is now live!

      Why?

      Increased reliability - less server errors


      Increased availability - less downtime


      Increased security - keeping us and you secure


      Increased capacity - ability to serve you better


      Increased speed - less waiting for things to load


      Faster development - server and service updates will come faster


      What are the changes?

      Move from a single AWS EC2 instance to AWS ECS (Elastic Container Service)


      Distributed computing


      Load balancing


      Git management of server files and filesystem


      Redis caching


      How?

      AWS ECS (with 10 EC2 instances)


      AWS ElastiCache (Redis)


      AWS Load Balancing


      AWS EFS (Elastic file system)


      Please bare with us as I continue to tune the server for maximum performance. Slow loading speeds may occur temporarily. I thank everyone for their patience.

      Please post on this thread if you experience any issues other than slow loading times.
        • Like
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Sad
        • Haha
        • Thanks
        • Like
      • 90 replies
    • This release will:

      Add new internal framework for capturing exceptions


      Fix issue with not selecting the last column in world hopper (Thanks @Todd)


      Add a message about pin usage in Banking#openBank (Thanks @Todd)


      Disable the firewall by default (Thanks @Todd)


      Fix handling of the welcome screen after login (Thanks @Encoded)


      Fix wrong amount bank withdrawal (Thanks @Encoded)


      Fix Screen#isInViewport


      Fix Game#isInViewport (Thanks @Encoded)


      Call onBreakEnd for ListenerManager Breaking Listeners (Thanks @Encoded)


      Fix Prayer#getPrayerPoints NumberFormatException (Thanks @JoeDezzy1)



      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Thanks
        • Like
      • 28 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...