java.lang.NoClassDefFoundError: org/json/JSONObject in customised jar file

Viewed 196

I created a jar file that using customized JSONObject class when I include it in my project in pom.xml i am getting the above error. When i import it using IntelliJ it only works in IntelliJ but I wasnt to share the jar file. How can I make my customized file be incorporated with the project?

<dependency>
    <groupId>com.roufid.tutorials</groupId>
    <artifactId>example-app</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/yourJar.jar</systemPath>
</dependency>
1 Answers

This is what I did

  1. Run below command in project root (the location that contains `pom.xml file)
    .\mvnw install:install-file -Dfile='src\lib\custom.json.object-0.1.0.jar' -DgroupId='com.custom.json.object'  -DartifactId='com.custom.json.object' -Dversion='0.1.0' -Dpackaging=jar
  1. In pom.xml I added the below line
        <dependency>
            <groupId>com.custom.json.object</groupId>
            <artifactId>com.custom.json.object</artifactId>
            <version>0.1.0</version>
        </dependency>
Related