Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
TileManager.class.getResourceAsStream("maps/Level_0.json")
works fine if I compile everything, but when I put it in a jar, it returned
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonDeserializer



My code for loading the JSON file is:
Java
InputStream is = TileManager.class.getResourceAsStream(src);

    assert is != null;
    content = new BufferedReader(new InputStreamReader(is))
            .lines().collect(Collectors.joining("\n"));

    System.out.println(content);
    data = Converter.fromJsonString(content);


Where src = "/maps/Level_0.json"

The location of `Level_0.json` is `src/res/maps/Level_0.json` and `res` is a source folder.

[x] I have imported all the libraries into the jar file.




I am using IntelliJ IDEA and /res is a source folder

What I have tried:

The location of `Level_0.json` is `src/res/maps/Level_0.json` and `res` is a source folder.

I have imported all the libraries into the jar file.

I have tried to change the path(with the preceding slash, without it)
Posted
Comments
Richard MacCutchan 4-Sep-22 3:18am    
The exception is telling you that a class is missing. That has nothing to do with the resource file.
Hackcraft_ 4-Sep-22 8:01am    
Ok, i will check again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900