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
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 briareos2285
      Just got a new Windows 10 Home x64 Laptop. Going through my usual install method and finding that I cant get looking glass to work. I have followed a few "old" guides, because I cant find any that are more recent. I am installing Java SE Development Kit 8u251, I am choosing the x86 version since the only OSbuddy cross platform .jar  file is 32bit. Its worked fine in the past. I then open Osbuddy, and then Open Tribot. I leave it on the default Tribot Version of 10.24.1. I select the java version for Tribot to use to be the JDK and not the jre. I changed the Heap Size to 1024 MB and login. I minimize Osbuddy, then I click New Client(Looking Glass). The Screen goes to black and says " Waiting for a Runescape client.... currently waiting for a valid client. List of detected java applications below." and there is nothing Below. I also tried a backup method that used to work as well, which was to instead click New Client (Osbuddy) and then manually select the Osbuddy .jar file which would open up Osbuddy and Create a Looking Glass Tab that mirrored Osbuddy. This no longer happens either. Ive also deleted the Hooks and Caches using Naton's Java Executable. I have also defined the correct Paths in my Computers Environment Variables.
      Im at a loss for what to do. Any help greatly appreciated
    • By Optimus
      Hey guys, Optimus here
        I noticed that TRiBot was lacking a good FREE auto fighter, so I decided to release a Lite Version of Optimus Combat & Magic for free!
      This version of the script has had certain features disabled, but is still very rich in features, so enjoy   To activate the script on the repository, please use the following links:
        https://tribot.org/repository/script/id/3097-optimus-combat-magic/ - Lite Version

      https://tribot.org/repository/script/id/651-optimus-combat-magic/ - Premium Version
      Note: There is a 10 hour FREE TRIAL for anybody who wants to try out the PREMIUM VERSION of the script on the repository
        Preview:   Features Overview: (Certain features are disabled in the Lite version).
      Supports CLI Launcher & Script arguments:
      Enter the name of your GUI settings as the script argument and you'll be botting in seconds!
      Combat features:
      Kills every monster in the game including but not limited too:
      ~Chickens
      ~Cows
      ~Goblins
      ~Giants
      ~Al-kharid warriors
      ~Chaos druids
      ~Yaks
      ~Experiments
      ~Stronghold of security
      ~All slayer dungeons
      ~All slayer monsters (Also uses finishing items such as Bags of salt, ice coolers, rock hammers, rock thrownhammers etc)
      ~Dragons (Including Brutals, and will keep safe distance if you're using ranged/magic)
      ~Crabs (Sand & Rock crabs + makes them aggressive again)
      ~Wyverns
      ~Kalphites
      ~Dagannoths
      ~Cave Kraken & splashing Kraken boss
      ~Wilderness monsters
      ~Nightmare zone bosses
      And hundreds of different monsters, literally anything else you can think of!
      Ironman mode:
      The script now supports ironman and ultimate ironman mode accounts, and will only attack / loot your own monsters on those accounts.
      Intelligent combat system that supports the following:
      - All food types + bones to peaches
      - Banking for more supplies at every bank in RS
      - All special attacks + weapon switching
      - All potion types (Including NMZ potions)
      - Full prayer support + quick prayers + recharging prayer at altars
      - Dwarf multicannon support + anti decay
      - Guthans for healing
      - Safe spotting
      - Worldhopping when certain conditions are met
      - All magic spells supported + can re-equip staffs and setup autocast for you automatically
      - Progressive training system so the script can automatically switch training methods / equipment when it levels up.
      Intelligent looting system that supports the following:
      - Looting by item name or ID
      - Loot items by item price (E.g loot all items over 500gp)
      Ironman looting - Only loots from monsters you've killed
      - Loot using telekinetic grab
      - Bury bones you loot
      - High alching the loot you pickup
      - Accurate profit calculations & tracking
      - Automatically uses the looting bag & herb sack 
      And much much more...
      Magic features:
      The script is also an AIO Magic script that supports every single combat AND non combat magic spell available on the Regular,Ancient and Lunar spellbooks.
      Including:
      All combat spells
      All cursing spells
      All enchantment spells for jewelry and bolts
      Superheat item
      All teleport spells
      All alchemy spells ( Can combo alch between casts to double your xp )
      Splashing
      The script can also train with the following lunar spells!
      Humidify
      Plank make
      Superglass make
      Tan leather
      Spin flax
      String Jewellery
      and More!
        To activate the script on the repository, please use the following links:
        https://tribot.org/repository/script/id/3097-optimus-combat-magic/ - Lite Version

      https://tribot.org/repository/script/id/651-optimus-combat-magic/ - Premium Version
      Note: There is a 10 hour FREE TRIAL for anybody who wants to try out the PREMIUM VERSION of the script on the repository   Gallery:    
    • 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
  • Our picks

    • Over the past few months, I’ve been working diligently on a new project - TRiBot X. Everything has been written from the ground up, with all of the best practices of software engineering. Every aspect of TRiBot has been re-imagined to support three main goals: flexibility, useability, and reliability.
      • 31 replies
    • Come give us feedback on the next version of TRiBot!
      • 74 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
      • 23 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.
      • 90 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...