Reputation: 5176
I have a .java
file that makes use of JSON
library, it imports the library's package:
However the package isn't recognised, so I tried to add the library to my project:
But it didn't work:
My library is located inside Root/libs/LibraryFolder1/LibraryFolder2/.java files and .classe files and .jar file
I tried importing both .jar and .java and library as a whole (by clicking on the root folder). Neither worked.
EDIT: I've also tried running a command:
mvn install:install-file -Dfile=C:\xampp\tomcat\webapps\Root\libs\LibraryFolder1\LibraryFolder2\Craps.jar -DgroupId=org.json -DartifactId=json -Dpackaging=jar -Dversion=20150912 -DgeneratePom=true
which gives a BUILD SUCCESS
result, but doesn't seem to change anything.
Upvotes: 1
Views: 112
Reputation: 32550
Since you are using Maven as your dependency (aka libraries) management, you cannot add it in your ide and expect it to work. It will be overriten to what you have in your POM file when you synchronize the project. Moreover, if you would make this to work from IDE, compilation would fail on CLI so bye bye every auto build tools.
To make this work, you mas add your local JAR to your local Maven repository and include it trough POM file.
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
After you install your Craps.jar as Maven artifact, include it in dependencies section in POM file.
Upvotes: 1