Elasticsearch without Maven - java

Recently I have begun working on a Java Spring project that does not use Maven and I need to build elasticsearch functionality into the program but I cannot find any information about how to import elasticsearch without the use of Maven.
Has anyone ever had to do something similar?
Is it maybe possible to just use Maven on this one part of the project?
Thank you for any help.

Maven just provide you a way to manage your dependencies. So, if you manage your dependencies in directly downloading JARs, you just have to download all the dependencies you needs and include them in your classpath.

As #Camille Gerin-Roze said , all you need is to download the ElasticSearch dependencies and add them to the classpath.
A place to start is :
https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch/2.3.5
And using the "Download Jar" link
If you scroll down and read the part that says "Compile Dependencies (32)" , it will tell you what other dependencies you need to download manually and add to the class path.
Please note that each of these dependencies may or may not have co dependencies that you may need to download and add to the classpath as well.

Related

Including dependencies in Java project on Intellij/Maven?

This sounds dumb but is there anyway for me to specify dependencies for my Java project like how I would in a package.json file so that someone else who was to download the project code from my GitHub repo, would be able to run it without any errors or missing libraries?
I have never tried using external Java libraries before, such as apache commons. The most I ever used was JavaFX but on a personal project level. My main concern is that if I were to push my code up to the repo and have someone else clone it. It might not run properly as the imported libraries are not downloaded.
Is there something similar to package.json dependencies where the person who runs the code would automatically download all dependency libraries and have it run on their system?
You can use Maven or Gradle for this purpose. Maven has pom.xml where you can specify all your dependencies. Similarly gradle has build.gradle which does the same job.

Install RestEasy with dependencies?

I want to use RestEasy in my Java server project, but I don't want to use Gradle or any other dependency management tool.
Instead, I want to get the jar files for RestEasy, as well as anything else that they depend upon, and install them in my project.
I can't figure out a straightforward way to do this. All documentation I can find either ignores the dependencies or assumes you're using Gradle.
I also don't want to manually guess and hunt down the dependencies myself since that seems error-prone.
I'm willing to use Gradle as a one-time process if there is a way I can get it to download all of the dependencies for me and put them in a place where I can extract them.
What's the best solution to this problem?
For using gradle as a "one-time process" you could use
gradle app:dependencies
For details look into the answers to this question: Using gradle to find dependency tree
Also, with maven (if you'd prefer that) it would be
mvn dependency:tree

Hibernate Validator: Must I use Maven?

From hibernate.org: http://hibernate.org/validator/documentation/getting-started/
I saw Prerequisites:
Java Runtime >= 6,
Apache Maven
However, "maven" is not even mentioned in the following:
http://www.aviyehuda.com/blog/2010/04/14/using-hibernate-validator-to-cover-your-validation-needs/
Our current project is not maven-based, a student project. Could we still use hibernate validator without using maven? Or is there any better choice for hibernate validation?
Maven is not required. The main reason you want to use Maven is that it makes downloading all the package dependencies super easy.
If it's just a small student project, and you don't want to use Maven, then just download the jars that you would otherwise have downloaded with Maven.
You can manually download the jar files here : http://hibernate.org/orm/downloads/
Maven is optional. But it's a very helpful tool for building Java projects (via many phases like compile, test, package, install...). You'd better learn to use it.
In your question, the hibernate-validator jar will depend on other jars such as hibernate-jpa, validation-api, joda-time...
It means you can not run your project with only hibernate-validator jar file. You need to collect all the required jars together.
Maven will automatically resolve it for you.
You can download from:
https://repo1.maven.org/maven2/org/hibernate/hibernate-validator/5.2.4.Final/hibernate-validator-5.2.4.Final.jar
Then add this file jar to your project manually. As you seen, downloading jar file is an alternative way when not using Maven.

Implementing Maven for an existing project

I have a project implemented in ADF.
I need to build it using Maven now.
I wrote the POM but now stuck at adding dependancies.
There are way too many JAR files, specifically about ADF, Toplink etc which I believe I will need to put in my POM.
Now, only way till now i could figure out is to go to each JAR, open manifest file, get version etc, and then get the dependancy block from maven online repository.
Is there a diff and easier and faster way of doing it.
Please help!!
Note: Chances are high that my question may sound illogical or stupid cause I have been using maven only for a week now.
-Santosh
If you are using a decend IDE, it could resolve your dependencies for you. If it can't import a class, you can ask it to look up the class in the Maven repository. Then you can choose which dependency to add to your pom.xml.

How to specify dependency on tomcat libraries with gradle

A bit of background about my knowledge level: I'm currently trying to learn how to build a project with gradle. So far I don't have much experience with build tools (almost none). I do understand the general idea and have seen ant and maven files before but never written them myself. Until now I just used other peoples build scripts or configured my builds using Eclipse. So I might be on a completely wrong track here, if so please point me in the correct direction.
Also, I sadly don't have much experience building jars by hand.
I have an Eclipse project which I want to compile into a jar. Required library jars are on my local file system. I managed to make gradle use these via
dependencies {
compile fileTree(dir:'lib', include:'*.jar')
}
in addition I have my source files in src/main/java and just use apply plugin: 'java' in the build.gradle file. Trying to build the project with gradle build seems to do the right thing, as far as I can tell.
However, the library is supposed to be used in a web project running on a tomcat and makes use of some libraries that are supplied by tomcat, as far as I understand. E.g. I'm using javax.servlet.http.HttpServletRequest.
The project works fine in Eclipse, but there I have the tomcat library added to my Eclipse build path. When I check in Eclipse I can see that javax.servlet.http.HttpServletRequest is part of the servlet-api.jar which is part of the Tomcat library.
Now, when I build the project I get build errors because the java compiler cannot find the class because I didn't specify the servlet-api.jar in the dependencies. I guess I could download it somehow (or learn how to specify it as an external dependency to make gradle download it from some repository) but I am not sure whether that would be correct.
Is there a way to tell gradle to use the same library that Eclipse uses? Or some other general way to tell it about all the tomcat jars, the same way I can simply add the complete Tomcat library in Eclipse?
Or do I actually need another copy of these jars somehow and have to specify each one individually?
Also, do I need to add these library jars to my build-result library jar? As far as I know I need to add any jar I depend on to the resulting jar as well. But then again, I have read somewhere that some libraries are supplied by tomcat itself so they would have to be part of any war deployed on it.
I'm afraid, I'm confused by the combination of how to build a jar-file to be used in a war-file to be deployed on a tomcat using gradle and I don't know from which of these parts my problems originate. I hope someone reading this can help me untangle my thoughts and point me in the right direction or at least tell me how to add the jars included in the Tomcat library to my gradle dependencies.
With Gradle, whenever you add files or directories as dependencies, they are not treated as full-fledged artifacts (with group, name and version), but rather as simple files containing classes. It means that Gradle will not perform any conflicts resolutions on them, or pull transitive dependencies.
For you, just to get started, I recommend just to add tomcat dependency. Make sure it is the same version as the one in Eclipse.
apply plugin: 'war'
repositories {
mavenCentral()
}
dependencies {
providedCompile 'org.apache.tomcat:tomcat-catalina:7.0.47'
}
Also, look into Eclipse Integration Gradle project as a long-term solution.

Categories

Resources