0

In project I used library org.json. Everything works fine in the editor. When I build the project, move the "out" folder to another machine (Debian), and run Main.class via console, I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject
        at gro.nn.lead_updater.Config.<init>(Config.java:30)
        at gro.nn.lead_updater.Config.getInstance(Config.java:23)
        at gro.nn.lead_updater.Main.main(Main.java:23)

I don't see any changes before and after adding the library in the out folder. Project structure below

Here project dependencies

Project structure

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 1
    You also need to have the library on the classpath when running your application. – Mark Rotteveel Apr 13 '22 at 15:15
  • pls, tell me how to run app in debian machine with dependency org/json in jar file. Others classes with .class – Дмитрий Гаврилов Apr 13 '22 at 15:16
  • @markRotteveel, i tried use java -cp com.company.Main . Its not help – Дмитрий Гаврилов Apr 13 '22 at 15:18
  • 1
    See https://www.jetbrains.com/help/idea/debugging-your-first-java-application.html. You need to create the artifact jar with all the dependencies included in it (with the class files from the jars as well). See also https://www.jetbrains.com/help/idea/artifacts.html. – CrazyCoder Apr 13 '22 at 15:48
  • 1
    You need to use `java -cp ; com.company.Main`, or if it is an executable jar, `java -jar ` and make sure that the other libraries are listed in the the `Class-Path` manifest entry, and that those libraries are in the right relative location. – Mark Rotteveel Apr 14 '22 at 07:18

0 Answers0