Click here to Skip to main content
15,868,158 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I used IntelliJ IDEA to create a Java program. The program works in the editor, but when I build the artefact, it shows error
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonDeserializer

caused by
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.JsonDeserializer


The program uses Jackson.core and Jackson.databind to read JSON data.

Here is the code:

Java
String content;

        InputStream is = tile.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);


The error is at line 76: data,

What I have tried:

I have selected all the libraries and put them in Output Layout

I have tested, and the code works fine when running from IntelliJ IDEA.
Posted
Updated 5-Sep-22 1:50am
v2
Comments
Richard MacCutchan 5-Sep-22 4:02am    
"The error is at line 76: data"
What error and what is the code that causes it?
Hackcraft_ 5-Sep-22 7:47am    
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonDeserializer
at tile.TileManager.loadMap(TileManager.java:76)




Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.JsonDeserializer
Richard MacCutchan 5-Sep-22 9:10am    
And as I already told you the error is telling you that Java cannot find a specific class. So either the class does not exist on your system, or it is in a location that Java is not searching. So check your environment settings, and your classpath parameter.

1 solution

This is also the same issue as Myclass.class.getresourceasstream() unable to find resources in JAR, but it can in .class[^], which you already reposted at Code returned java.lang.noclassdeffounderror in jar but not in compiled files[^].

If you have additional information to add then please use the Improve question link in the original question, and add complete details of what is not working.
 
Share this answer
 

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