Jump to content

java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException


Sana

Recommended Posts

Java noob here. Seasoned in other languages but haven't ever used Java in production.

I've already Googled and found solutions to this problem, but they do not work for me. Posting here just to make sure it's not an OSBot-specific issue. 

I followed step #1 on this OSBot tutorial. I added json-simple-1.1.jar to my project so I can use the following imports:

import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

I also followed this video on how to ass a .jar to your classpath.

The issue occurs when I rebuild the artifact and refresh scripts in OSBuddy, after running it I get this stack trace saying it can't find the class, even though I already added it and it builds fine in IntelliJ IDE:

Quote

java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
    at script.REDACTED.onStart(REDACTED.java:145)
    at org.osbot.rs07.event.ScriptExecutor.iiiIIiiIIiIi(ah:57)
    at org.osbot.rs07.event.ScriptExecutor.start(ah:1)
    at org.osbot.FA.iiiIIiiIIiIi(zv:193)
    at org.osbot.zA.iIiIIiiIiiii(wab:15)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 8 more

Anyone know what's going on here? How can I get this new package added to the classpath so the error goes away?

Edited by Lansana Camara
Link to comment
Share on other sites

4 minutes ago, Token said:

make sure you include the dependencies in the exported jar (simple json dependency in this case)

Hey, thanks for your response. Can you elaborate on this part a bit? In IntelliJ IDE 2019.1, I went to "File -> Project Structure -> Modules -> Dependencies" and then I added the json package .jar and also checked the box "Export" next to it, then hit "Apply" and "OK". 

This does not work, either.

Link to comment
Share on other sites

4 minutes ago, Lansana Camara said:

Hey, thanks for your response. Can you elaborate on this part a bit? In IntelliJ IDE 2019.1, I went to "File -> Project Structure -> Modules -> Dependencies" and then I added the json package .jar and also checked the box "Export" next to it, then hit "Apply" and "OK". 

This does not work, either.

The script jar is built using an artifact, so look under artifacts and add the simple json jar under the output structure

Link to comment
Share on other sites

4 minutes ago, Token said:

The script jar is built using an artifact, so look under artifacts and add the simple json jar under the output structure

Ugh, IntelliJ is so stupid. Did what you said already, added the .jar from Project Libary and Global Library. Clicking "Library Files" to add it doesn't work, you have to click "Extracted Directory" to add it. Every StackOverflow answer says to click otherwise. 

Whatever, it's solved now. Thanks a bunch.

Link to comment
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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...