Use external project in JSP - java

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

Related

Error jsoup in Eclipse

I am still receiving errors due to jsoup in eclipse. I have dropped the JAR in the project's tab, rightclick the JAR file and then chose Build Path > Add to Build Path but it still does not work.
http://imgur.com/SCqLxWN
Could you please help me?
#Thank you for responses!
I have done as you advised me but it still does not work.
http://imgur.com/Y5B9Em2
I am just a beginner but when I am using other packages everything works, I have troubles only with this jsoup. Do you have any other ideas?
Create a folder named libs in the root of your project and put your jar files here. Then go to project Properties, under Java Build Path > Libraries click on Add JARs... and select you jar file, under the libs folder.
Try to remove the following code as your class is inside the default package.
package org.jsoup.examples;

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

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.

PrintCommandListener is missing

I'm trying to upload a file via FTP client using Java, but when trying the:
import org.apache.commons.net.PrintCommandListener;
the PrintCommandListener is show in red. I verified my library and it does include commons.net. What should I do?
PrintCommandListener is in fact in Apache Commons Net. For example, if you download the current version, the jar you need to include in your build path is commons-net-3.3.jar. If this single jar is seen by your compiler, then the class should be recognized. Make sure there are no other classes called PrintCommandListener (for example custom ones that you might have written) in your build path.
If using an IDE (such as eclipse) make sure the jar is on your build path. For example, with Eclipse right click project, go to Java Build Path and click Add JARs. Navigate to the location of your jar file and add it.

Importing JSON into an Netbeans project

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.

Categories

Resources