0

I have a project directory:

 .
├──  data
│  ├──  items.json
│  └──  users.json
├──  jparser
│  ├──  Item.class
│  ├──  Item.java
│  ├──  jackson.jar
│  └──  Person.java
├──  README.md
└──  spec.md

Where I want to use the jackson.jar file without using Maven or Gradle.

I tried following the instructions on another post, with the following code:

package jparser;
import jparser.jackson.databind.ObjectMapper;

public class Item {
    // some code here
}

and executed it (following the UNIX instructions) with:

javac -cp '.:jparser.jackson.jar' jparser/Item.java

where I get the following error:

jparser/Item.java:2: error: package jackson.databind does not exist
import jackson.databind.ObjectMapper;
                       ^
1 error

Other things I have tried (which still returned errors):

javac -cp '.:jparser/jackson.jar' jparser/Item.java
javac -cp 'jparser.jackson.jar' jparser/Item.java
javac -cp 'jparser/jackson.jar' jparser/Item.java
  • your classpath treats the folder like a package, why? `'.:jparser/jackson.jar'` should be a little more correct – f1sh Feb 18 '22 at 02:33
  • I have tried that, my bad for not mentioning it. It still doesn't work. Updating the post so that others know too – Tahmin Ahmed Feb 18 '22 at 02:42
  • Perhaps the `import` package is wrong? Could you validate that the ObjectMapper class is inside the jackson.jar file? – admlz635 Feb 18 '22 at 02:58
  • `ObjectMapper` is in the package `com.fasterxml.jackson.databind` – tgdavies Feb 18 '22 at 03:00
  • I may be understanding it wrong, but `ObjecMapper` is supposed to be there [according to the javadocs](https://javadoc.io/static/com.fasterxml.jackson.core/jackson-databind/2.13.1/index.html?overview-summary.html) – Tahmin Ahmed Feb 18 '22 at 03:03
  • I also tried `com.fasterxml.jackson.databind` in the java code, gives the same error – Tahmin Ahmed Feb 18 '22 at 03:05

0 Answers0