Java – The type com.fasterxml.jackson.core.JsonGenerator cannot be resolved. It is indirectly referenced from required .class files

eclipsejacksonjava

Here I am using Jackson data binder 2.4.1 jar library in my eclipse project to convert an object to a json format. And here is my code:

ObjectMapper mapper = new ObjectMapper();
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
mapper.writeValue(wr, content);

but in the last line mapper.writeValue(wr, content); it gives an error saying

The type com.fasterxml.jackson.core.JsonGenerator cannot be resolved. It is indirectly referenced from required .class files

I have studied and found that when a jar file's class is dependent on another class which is unavailable then this type of error occurs. But from where I am using this code snippet there is no issue like this. But I have failed a lot of time by changing the JAR version but nothing solved this issue. How can I solve this, please help

Best Answer

You need both jackson-databind and jackson-core on your classpath.