Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
rid_rj
Contributor III
Contributor III

Erreur : java.lang.NoClassDefFoundError: org/json/simple/parser/JSONParser

Bonjour les amis,

J'ai un code java qui permet de récupérer les clés et les valeurs de fichier json avec un code java sous talend car mon fichier contient une partie dynamique et j'arrive pas à trouver un composant dans talend pour résoudre mon problème.

 

J'ai reçu l'erreur suivant java.lang.NoClassDefFoundError: org/json/simple/parser/JSONParser

La plupart des explications que j'ai trouvé disent que les jars JSON installé dans Talend sont incorrects.

J'ai supprimé les jars et j'ai ajouté des autres jars recommandés mais le problème existe encore mais j'ai un doute que je n'ai pas supprimé réellement les mauvais JARS

 

Avez vous une idée comment je peux nettoyer Talend et installer du nouveau les jars JSON.

 

Le code Java  :

package routines;
import java.io.FileReader;
import org.json.simple.JSONObject;
import org.json.simple.parser.*;

public class getKeyFromFile { 
	    public static void main(String filepath) {
	        JSONParser parser = new JSONParser();
	        try {
	            Object obj = parser.parse(new FileReader( filepath));
	            printJSON((JSONObject) obj);
	        } catch (Exception e) {
	            e.printStackTrace();
	        }   }
	       
 public static void printJSON(JSONObject jsonObj) {
	            for (Object keyObj : jsonObj.keySet()) {
	                String key = (String)keyObj;
	                Object valObj = jsonObj.get(key);
	                if (valObj instanceof JSONObject) {
	                    // call printJSON on nested object
	                	printJSON((JSONObject) valObj);
	                } else {
	                    // print key-value pair
	                    System.out.println("key : "+key);
	                    System.out.println("value : "+valObj.toString());
	                }          }        }       }

 

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Have you configured your routine with the correct Jars? To do this, right click on the routine and select "Edit Routine Libraries". A window will appear where you can add libraries to support your code in the routine.

View solution in original post

2 Replies
Anonymous
Not applicable

Have you configured your routine with the correct Jars? To do this, right click on the routine and select "Edit Routine Libraries". A window will appear where you can add libraries to support your code in the routine.

rid_rj
Contributor III
Contributor III
Author

Thanks you, your solution fixed my problem 0683p000009MACn.png