Add external library in Intellij - java

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

Related

Importing Apache Math Classes in Eclipse ( OSX )

I have downloaded the Apache Commons Math Package from their website, and extracted the .jar files. Specifically, I took commons-math3-3.6.1.jar, and added it to my /Libraries/Java/Extensions directory ( on OSX ).
I then added this .jar file as an External Jar in my Eclipse Project's Build Path.
What I would like to do is use the WeightedObservedPoints class. But when I write the following line:
import org.apache.commons.math3.fitting.WeightedObservedPoints;
I see the following error:
Access restriction: The type 'WeightedObservedPoints' is not API (restriction on required library '/Library/Java/Extensions/commons-math3-3.6.1.jar')
Does anybody know how I might solve this problem? It doesn't make sense that this class would not be in the public API. Am I missing a .jar file to add? There were several in the original package, but they all seemed like documentation and other optional features like testing.
Thank you for any advice.
Thanks to Ivan, I did find the answer inside his link. The steps to fix it for me were:
Edit the JRE System Library on the Build Path option from the Project Properties.
Change the "System Library" option to "Use Alternate JRE", but to leave it with the default choice ( which is the same as what was set for Execution Environment )
The error is gone. Definitely don't know why this works though.

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.

Edit Library in Eclipse

I am trying to enhance a library. The library is in the Referenced folder of eclipse. I presume in that folder I can't just edit the code so I guess I have to import the whole .jar file as kind of a project, but how can I do it in eclipse .....
The right way to do it is to find/download the source code for the library. The ugly way to do it is to decompile the library.
After that, edit the source code, and run against your custom version.
You probably need some sort of Java code decompiler to get the source code for that library and then make an eclipse project based on its source. It will be tedious and you will need to setup the dependencies and all that. However you might want to see if the source for that project is already somewhere on internet, eg open source libraries. One better approach could also be extending that library by means of extending classes and that.

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.

How do I use API's in Netbeans for JAVA?

Ok so there are tonnes of API's out there. I need to use some of them like JIntellitype, iText, docx4j etc. But the problem is I do not know how to go about it in Netbeans.
I tried following the instructions in readme for all these API's but it does not work since there is something I am doing wrong. I am a newbie at JAVA and Netbeans.
Thanks!
[Update]
This is what I tried to do.
I downloaded the JIntellitype API. It contains lots of files including JAR,DLL,CPP etc. When viewed through File->Open Project from Netbeans this folder is displayed as a project.
I created a new JAVA Application project from Netbeans.
I right clicked the Project->Properties->Library and added the API folder there.
Then I tried importing one of the classes from the API called HotkeyListener as follows:
import jintellitype.HotkeyListener;
I received an error saying package does not exist.
Generally you have to add your API jar to your project. Open project properties, find where external libraries are added and add them. Once you are done you can import library classes and use them.
like AlexR said, you should add the jar file with the jintellitype.HotkeyListener in it, not just the directory. You can open jar files with winrar, winzip, 7zip etc...
Regards

Categories

Resources