0

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).

Adriaan Marain
  • 294
  • 3
  • 10
  • its `lib` folder not `library` exactly @AdriaanMarain – Vikrant Kashyap May 24 '16 at 09:07
  • I meant [this](http://i.imgur.com/llyCWAX.png). Mine looks like [this](http://i.imgur.com/6gW4tHc.png) (no Libraries folder). – Adriaan Marain May 24 '16 at 09:46
  • during creation of new project you have done some mistakes. that'y this problem occurs . because `lib` folder exists in default setup of Project. @Adriaan – Vikrant Kashyap May 24 '16 at 10:37
  • [Here are 2 new projects I created to show my issue.](http://i.imgur.com/N3lJQ9D.png) I'm creating an xlet, which means I have to use the Blu-Ray Disc Java Project, which just doesn't appear to come with the Libraries folder. Are you answering my question from a Java standpoint, or MHP/xlet? I'll probably just use a different IDE if I can't resolve my issue. Thanks for the help though! – Adriaan Marain May 24 '16 at 10:57

1 Answers1

0

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.

MarGraz
  • 61
  • 9