Want to import a library into my Java project - java

I would like to add this to my imports and use it to verify URI addresses however, I am having trouble figuring out how to properly import this http://www.jdom.org/docs/apidocs/org/jdom2/Verifier.html. Do I have to update my Maven repo? I understand that it is included in java.lang.Object, but when I include that it can't find Verifier.
Can someone please help me understand the problem here?
Ejay

You can get JDOM 2.0.2 from Maven Central Repository:
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>2.0.2</version>
</dependency>
Here is a link to Maven Central Search for JDOM 2.0.2
I just pulled down jdom-2.0.2.jar from here and verified that it does contain org.jdom2.Verifier.class

The jdom2 project isn't available (yet) through Maven. (You can't just add some XML to your POM.)
You can download the JAR file here:
http://www.jdom.org/downloads/index.html
This SO question discusses how to use a plain JAR file with your Maven project:
Can I add jars to maven 2 build classpath without installing them?

Related

Not able to find javapasswordsdk.PSDKPasswordRequest maven dependency

I am working on migrating one project to maven. I can see 2 import statements in legacy code like:
import javapasswordsdk.PSDKPasswordRequest;
import javapasswordsdk.exceptions.PSDKException;
I dont see any maven dependency available in maven central for these imports to add in my pom.xml.
Can anybody help me to get this jar ?
The classes mentioned are part of a commercial offering called cyberark.
See the following Cyberark Enterprise vault product page
This library won't be up on maven central.
If an internal maven repo exists it may be there. Otherwise, this library is often packaged with application using the provided scope
<dependency>
<groupId>com.cyberark</groupId>
<artifactId>JavaPasswordSDK</artifactId>
<scope>provided</scope>
</dependency>

Incorporate javadoc URL for external jar dependency in Maven

I've searched for similar questions already asked, but most have been related to generating new java documentation using javadoc for all of the included dependencies.
My question is more basic - I just want to be able to view the javadoc documentation for an external library in Eclipse when using the "Ctrl+Space" or hovering over an object/method.
For example:
I have a dependency for the "commons-cli" library
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.3</version>
</dependency>
By default though, I am not able to view the API documentation for the classes located in this library. I can do this manually, by using the Project Explorer to navigating to the "commons-cli-1.3.jar" file located in Java Resources->Library->Maven Dependencies and then specifying the URL (https://commons.apache.org/proper/commons-cli/apidocs/) for the javadoc in its property dialog box.
Is there a way to incorporate this information into the maven pom.xml file? That way, I don't have to do this manually for every dependency and also it works for anyone checking out my project to their own computer.
Thanks in advance.
Run mvn dependency:sources which downloads the sources for the libraries. Check Maven repo dir (normally ~/.m2 ) if you have sources there - there should be jar with the same name as the lib artifact but appended with -sources. Like this:
If this is the case and you still don't see the javadocs in IDE then you should setup your IDE to use Maven repo as a source for sources.

What is the best way of adding a jar file to a maven project if we could not find it the maven central repository?

I need to add the package "uk.ac.shef.wit.simmetrics.similaritymetrics"
to my maven project but I am not able to find any remote repository which contains it. I have to add it via dependency to the project, but not successful yet.
-I already added the jar file to the referenced library but in that wat I get the following error:
package uk.ac.shef.wit.simmetrics.similaritymetrics does not exist.
-Adding it through following dependency to the Pom.xml also does not help
<dependency>
<groupId>uk.ac.shef.wit</groupId>
<artifactId>simmetrics</artifactId>
version>1.6.2</version>
<scope>system</scope>
<systemPath>LocalPath\simmetrics-1.6.2.jar</systemPath>
</dependency>
Any help is appreciated!!
If this is a small project that you intend to only build locally or on a few machines then the simplest way is follow directions at the site below to add a 3rd party jar. Those instructions will help you install it in your local repository. You will need to do that for all machines that you intend to run the build on.
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
If you plan to run it on many machines then the best thing to do is to install the artifact to your own private repository. If that is the case then I suggest you create a project for it in version control. Then upload the file as part of that project.
I appear to be the current maintainer of Simmetrics. You can add this dependency to your pom file.
<dependency>
<groupId>com.github.mpkorstanje</groupId>
<artifactId>simmetrics-core</artifactId>
<version>4.0.1</version>
</dependency>
Simmetrics has been given a much needed serious overhaul since 1.6.2. You may have to adjust your code accordingly. For source code and documentation see https://github.com/Simmetrics/simmetrics

Is there a maven repository for flash-selenium.jar?

I recently moved to maven project and since then I found adding dependencies very difficult. Before that I just needed to download the jar and add to library folder .
Now I am searching flash-selenium.jar dependency but I failed to find any. So I added it manually in my C:.m2\repository\org\seleniumhq\selenium\flash-selenium folder but still it is giving error. So how can I use this jar in my maven project?Its a request to people those have 1500 points here , could you please create a label for selenium flash related problems. Thanks
There's no flash-selenium dependency in maven central, but there are other artifacts like:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0rc2</version>
</dependency>
the complete list:
http://search.maven.org/#search|ga|1|selenium
Maybe some of this fits what you need.

How to import org.apache Java dependencies w/ or w/o Maven

So the quick background is I am creating a java program, that uses many different imports
import org.apache.hadoop.conf.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.util.*;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
I know that Netbeans isn't finding these files because I do not have them on my computer. But is there a way to have Netbeans automatically connect with org.apache and retrieve these files? Or do I just have to go and download them. Someone recommended using Maven, but I am not sure if this is the right solution or how to go about that?
Thanks
Unless you use a Maven structure (see here getting started with Maven) you will have to download all jars manually.
If using only Hadoop (as in your example) this might not seem that much of a deal, but when working with big projects it is easier to declare your dependencies in a pom.xml file. It is much more easier than downloading X different jars, and you can easily move to a newer version of a library, rather than having to delete and and download another.
I saw that someone asked in a comment why people like Maven so much. Well, to be honest, I personally find it easy to use and very useful. Furthermore, a Maven project can be easily imported in IntelliJ, Eclipse or Netbeans, whereas creating for example an IntelliJ project can cause difficulties in importing it in Eclipse or NetBeans.
To get started using Maven with Netbeans, you can go to: New Project, Categories:Maven Projects:{Best Option}. Then in the project files, open pom.xml. Here is where dependencies for your project are added. If you are not sure what to insert try searching for your jar name + "maven" on the internet. The plugin for Netbeans is able to connect to the maven repository and autocomplete most fields.
Sample from: http://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.6
<project...>
....
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
...
</project>
Download the .jar file here: http://mvnrepository.com/artifact/org.apache.hadoop/hadoop-core/0.20.2
In Eclipse, right-click on your project, click Properties, search in the text box for Library, click on Build Paths, click Add External JAR, and select the file you downloaded from the link above.
You will have to download the jar-files yourself. Unless you start using Maven or a similar dependency management tool.
You must download them. The name org.apache.hadoop is a package name, and we only use the name of the site as a convention. See this tutorial on packages for more information. Essentially a package is a folder on your computer, often in the Java\jre\lib\ext\ directory.
Refer tutorial
http://www.tutorialspoint.com/hadoop/hadoop_mapreduce.htm
It mentions :-
Download Hadoop-core-1.2.1.jar, which is used to compile and execute the MapReduce program. Visit the following link http://mvnrepository.com/artifact/org.apache.hadoop/hadoop-core/1.2.1 to download the jar.
Not a netbeans user , but I'm sure that even in netbeans, you have a maven plugin.
"Mavenize" your project, and when you will perform mvn clean install, you will get these jars to local maven repository.
With Eclipse I use the m2Eclipse plugin and it works really well for me.
This of course depends that these jars can be found in maven repositories over the net, such as maven central repository.
I have final figured out my preferred way to create a new Hadoop project and import the dependencies using Maven.
Using NetBeans I create a new Maven project.
Then under project files, I open the pom.xml.
I finally add inside of
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>0.20.2</version>
</dependency>
After building with dependencies I am now ready to code.

Categories