Importing JSON.simple in a MHP project (Netbeans)

657 views Asked by At

I'm working on an MHP project using NetBeans. I need to import the JSON.simple library, but I'm having some issues.

In normal Java applications in NetBeans, you'd have the "Libraries" folder in your project in NetBeans. I don't have this folder, supposedly because it's an MHP project.

I've added the .jar file in my Tools>Libraries and in my Project>Properties>Java Sources Classpath. When I did the latter, NetBeans started to autocomplete for import org.json.simple.* and didn't give me any errors. But when I run my project, I still get the "package org.json.simple does not exist." error for the import line.

I'm guessing I still haven't added the library to my project properly, but I'm not sure what I'm doing wrong. I'm 100% sure there's a way to make this work, because I've seen my professor work with the library in an MHP project (I couldn't get his help because we haven't had a class in 2 weeks and he doesn't check his mail very often).

1

There are 1 answers

0
MarGraz On

I think that I found a solution, now I'm able to compile the project and it works on TV.

I used the uncompiled java file from JSON.Simple library, available here: https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/json-simple/json_simple-1.1-all.zip you can find these java files inside the folder: "json_simple-1.1-all\src\org\json\simple", then you need to copy all the files from folders "simple" and "parser", and put these files inside the Xlet project creating new classes with the original name of the java's file.

You need to put all these files in the root folder of your project, without creating a package or another folder.

After this, you need to remove the "package" import from the top of every imported file, and also you need to remove the "import", like: "import org.json.simple.parser.JSONParser". You need to check all the imported class for errors. After this you will be able to compile the project correctly.