Importing JSON into an Netbeans project - java

I need to import JSON library into netbeans.
How can I do that?
I searched on internet and I found this article.
According to this article when I import
import org.json.simple.JSONArray;
import org.json.simple.JSONObject
that, it must be work. But unfortunately it didn't work. and I get an error:
Package doesnt exist
Thanks for your help.

As the article says you need to add the simple-json library to your project:
http://code.google.com/p/json-simple/

For this we have to add Class org.json.JSONObject which available in json-20131018.jar.
We need to download this jar and add this jar to your buildpath.
for it in netbeans right click 'libraries' in the project list, then click add jar/folder.

Download jar from here : https://code.google.com/archive/p/json-simple/downloads
And then add it to your "libraries" in netbeans.
Added this answer, because other answer didn't provide the above link, which is the easiest to download jar from.

try add json-20131018.jar. This solved my problem.
http://mvnrepository.com/artifact/org.json/json/20131018

Or, instead of relying on the old version which uses the old import, use the newer version with the new import:
import com.github.cliftonlabs.json_simple.*;
For Netbeans, you can right click the project and go into Libraries to make sure the jar file is added into Classpath (not Modulepath). Press the '+' button to add it under that section by either by using a created library with the build jar and javadoc jar or, more simply, just adding the single jar file (json-simple-3.1.1.jar) directly to the classpath.
After doing this, the jar file should show up in the 'Libraries' folder under the project.

Related

Heroku API: adding the jar into NetBeans

Following up on How to obtain databse url etc without the heroku CLI I have added https://github.com/heroku/heroku.jar to my NetBeans project's library: "Add JAR/Folder" (I copied the jar first to /home/username/netbeans-8.2/ide/modules/ext) But HerokuAPI is not being recognized, and Alt-Space does not show any suggestions for imports, so I guess netbeans simply has not recognized the jar's contents. Maybe this thing is hidden in the default package, and so I can't import it?
EDIT: Here is the image
So, it is in the default package after all? How to fix this?
I had to create a new -- now Maven-based -- project and resolve the dependency using pom.xml, as explained on https://github.com/heroku/heroku.jar

Add external library in Intellij

I want to use this external library in my Intellij Maven project. I have tried to do it like official described and like often recommended here or here.
But always I try to type ReedSolomon or com.backblaze.erasure.ReedSolomon, ReedSolomon is marked red and Cntrl+b says "Cannot find declaration to go to". Also Alt+Enter gives me no posibility to import the class.
Other libraries are added and were recognized.
Isn't it possible to use this zip as external library? Do you have any ideas what I can try else?
Thanks!
You have to first unzip the library. It is not a .jar archive, but a package.
So you could create a new package in your project: com.backblaze.erasure. There you copy/paste all .java files from the unzipped directory javareedsolomon\com\backblaze\erasure.
Hope this helps you :)

implementing the NWalign.java alignment script for needleman wunsch algorithm

I'm trying to run the NWaling.java file found here. the code present at the link that I mentioned makes use of the jaligner library. I have downloaded this Java package from here. inside the zip folder there is a JAR file. I'm developing the code using eclipse. whenever I add this JAR file to the code there are some classes missing for example:
import jaligner.NeedlemanWunschGotoh;
&
import jaligner.matrix.MatrixGenerator;
also in the entire zipped folder there isn't any pom.xml file to allow me to import the entire folder as a maven project to eclipse. can somenone suggest me how to import this jaligner library and use it in eclipse? thanks.
You can download a community implementation of the jaligner algorithm from here.
Take a look at this project sources where you may perhaps find all the searched artifacts.
The full Eclipse project with the NWalign.java can be found here including .classpath file with all dependencies listed there.

Where to put downloaded java package?

I downloaded a javax speech class. I cant seem to import it in eclipse. It doesnt recognize it as an import. I think it is becasue i havent put the package in the right place. Where should i put it?
add the class/jar in your classpath
right click on your project --> java build path

Use external project in JSP

I downloaded a project from Google Code named 'mp4parser'.
Now I want to use it in my JSP page (specifically in a servlet).
How do I import it?
I use Netbeans.
In my project's properties I added a Library (Add JAR/Folder).
Then, in my servlet code I wrote
import com.googlecode.mp4parser.*;
But I get an error 'package don't exist'.
SOLVED
First I had to compile the mp4parser project, and then MANUALLY indicate the JAR file.
Netbeans couldn't find it on its own.
You should create jar of the project you downloaded and the add it to the class path and then you will be able to use it.
So you get compile time error ? The only problem that is happeing is your Jar is not in the Build Path. Please check How to add jar in netbeans

Categories

Resources