Trying to compile a .java file with some imports from fasterxml.jackson, like this (SDK 17 and maven):
javac -classpath out/artifacts/project/project.jar src/main/java/CollectionsProcessing/JsonHandler.java
And getting this error:
src/main/java/CollectionsProcessing/JsonHandler.java:6: error: package com.fasterxml.jackson.databind does not exist
import com.fasterxml.jackson.databind.JsonNode;
^
src/main/java/CollectionsProcessing/JsonHandler.java:7: error: package com.fasterxml.jackson.databind does not exist
import com.fasterxml.jackson.databind.ObjectMapper;
^
src/main/java/CollectionsProcessing/JsonHandler.java:17: error: cannot find symbol
ObjectMapper mapper = new ObjectMapper();
^
symbol: class ObjectMapper
location: class JsonHandler
Tried using -cp flag instead of -classpath, made sure all imports are fine in pom.xml, all libraries are added to output layout, but nothing is working.
Also went through similar questions on StackOverflow but haven’t found a solution.
However when I run the main of the target class directly through IntelliJ it is working. Also when I run mvn clean verify
it shows BUILD SUCCESS
. If anyone has any idea why it is not working on the command line I would greatly appreciate it.