[Java] NoClassDefFoundError
See original GitHub issueException in thread “main” java.lang.NoClassDefFoundError: org/json/JSONObject
I am wondering why it is so hard to make a Maven projects work fine with external JAR libraries. I’ve added the needed information to pom.xml. The project will download all of the required dependencies and also IDE doesn’t mark the imported packages or syntax markups as invalid.
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
I am trying to use org.json and org.json.simple, but it doesn’t matter how ever I am trying to import it. I’ve read around the internet about this error, but it doesn’t make any sense for me. I was so excited about it that I don’t need to configure something “hard” what I don’t understand, but now I have to. Normally I use Eclipse on PC, but when I’m not at home it would be awesome to code something at somewhere without installing the stuff on the PC I’m using.
In Codenvy, build and run processes take place on different nodes and different environments. This project produces /repo with quite a few jars and a startup script that is impossible to inject into a Docker container (Codenvy runners are Docker based). Thus, I recommend performing build and run in the same environment, i.e. in the runtime. What you need to do is create a new runner (the button is on the runner panel), install Maven there, perform build and execute startup script. You will also have to unbind the service from localhost -kalrsson from StackOverflow
So basically what can I do? I really would like to use Codenvy of course.
Issue Analytics
- State:
- Created 7 years ago
- Comments:19 (6 by maintainers)
Top GitHub Comments
@MPNull It seems you need to add Maven dependency plugin to copy your dependencies as jars to the lib folder, specified in your manifest.
Simply add the following to the pom.xml, build and run your project:
@ddementieva awesome, awesome, awesome! It was the solution! Luv U ❤️
That’s one of the reasons why I didn’t never treat a Codenvy about the problem. I were pretty sure that there’s something I’ve fuck’d up myself. Thank you a lot.