JavaFXGL how to get the library for java from maven - java

I am trying to use the javaFXGL library. Which is the java gaming library. I am not sure how to use maven to download the library to eclipse. Does anyone know a step by step way to download this. I need to this get some example code running.

I would be easier to get the help if you add your code in the question along with the problems/errors you are facing. Anyways I would suggest you to first read this and this to understand what is maven and how it works with Eclipse IDE.
After reading the articles you will understand that maven project has pom.xml file which is used for maven settings or you can say for Dependency Management, Build Management, etc.
To add the library you need to add its maven dependency in the pom.xml inside the <dependencies> tag like below:
<!-- https://mvnrepository.com/artifact/com.github.almasb/fxgl -->
<dependency>
<groupId>com.github.almasb</groupId>
<artifactId>fxgl</artifactId>
<version>0.2.9</version>
</dependency>
You can also find other dependencies on www.mvnrepository.com

Related

Importing Beat Link Java Library From Maven Central To Eclipse?

This is the first time I have encountered Maven so I don't really know what I'm doing here.
What I'm trying to accomplish is to import the java library Beat Link into my java code using Maven.
Could anyone please provide a simple step by step on how to do this in eclipse?
On maven central you got the maven dependency text -
<dependency>
<groupId>org.deepsymmetry</groupId>
<artifactId>beat-link</artifactId>
<version>0.6.3</version>
</dependency>
Once you create a maven project you should have a pom.xml file.
You need to add this text to the dependencies section of your pom.xml file.
If that doesnt make sense to you, do yourself a favor and read/watch a quick tutorial about using maven on a java project. It's pretty simple once you see how it works.

How to add dependencies to java project automatically based on the import statements?

I'm not familiar with using java package. Now I'm given a set of java files that import plenty of stuff. But there's no pom.xml file provided.
First I tried to directly compile the files, but was told com.amazonaws is not found. So I think I may need to download all the dependencies. But there are simply too many import statements so it seems not very practical to download them one by one manually.
Then I found that I may use maven. But after I tried creating this pom.xml
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.341</version>
</dependency>
</dependencies>
and use mvn package. I got an error telling me building failed. I thought that might be because I didn't specify all the dependencies. Is there a way to automatically pull dependencies based on import statements in the java files?
Maven is the right way to go. And you've made a good start.
Although Maven is very good about pulling "implicit dependencies", it can't "guess" everything. It sounds like you're going to have to add just a bit more to your pom.xml
SUGGESTIONS:
Read this:
https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-project-maven.html
Post the specific errors you're getting with your current pom.xml. Be sure to copy/paste the exact errors, along with updating the exact contents of the pom.xml that you used in that iteration.
Using MVN is best approach to add dependencies to you project. You need to write some more stuff in your pom.xml . You can go through this example https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html to create a maven project step by step

How to properly use any Java API

I have been trying to use the vget library/api to make my own youtube video downloader. The vget library can be found here: https://github.com/axet/vget
I have downloaded the zip on github and I imported the project into eclipse. However, I am confused to how I am supposed to properly use this API. Should I make a completely new project, and import the classes that I need or do I put my own source files in the project of the api?
I have read other threads concerning this problem. However, they all mention how a api is typically packaged in a JAR file, but in my case it is just files and classes. So I am confused to how I should properly use this api.
The vget project is a maven project. You can see that because it has a pom.xml file in the root folder of the project.
To use it, you don't even need to download the source, because the compiled jar files are already stored in the central maven repository. You can find more information about this here:
http://mvnrepository.com/artifact/com.github.axet/vget/1.1.23
(in general, you can use the http://mvnrepository.com/ site to search whether your library is available on the maven central repository. If it's even a mildly popular library, then chances are that it is)
What you need to do is to make your own project a maven project.
Here's a "5 minutes" starter guide that describes how to do that.
When you've done that, you just add the dependency on vget to your pom.xml file in the <dependencies> section:
<dependency>
<groupId>com.github.axet</groupId>
<artifactId>vget</artifactId>
<version>1.1.23</version>
</dependency>
Since you are making use of a 3rd party software, and not extending it with your own logic, the way to go is to create a new project, which references the 3rd party software.
You then construct your application and make it do whatever you need it to do. When it comes to using logic which is available within the 3rd party logic, you would then simply delegate that call to the 3rd party library.
I have seen on the link you have provided, that this is a maven project. You have to execute a maven package command, or maven install, so that the jar file will be generated.
With this jar follow the Bill's instructions, and add it as external library to your claspath.
When you do this, you will be able to invoke methods of that api.
Let us know if you need some help doing this in eclipse.
If your project is a maven project, you can solve dependencies problems just adding the dependency written on Readme file to your pom file.
The easiest and most automatic way is to use something like maven, ant, or gradle, that will automatically download and put the jars in to your classpath if they are in the central repositories. For example, in the maven configuration file(pom.xml) you can add this to the dependency list:
VGet Maven Repository
These build tools also allow you to add external jars if needed.
If
I would suggest you get familiar with Maven. At the bottom there is a Maven dependency you just have to include into your pom.xml, and then you can use the extension immediately.
Maven is a build platform which organizes your project in a technical way (convention over configuration, e.g. code is in /src/main/java, tests are in /src/test/java). The proper way is it to create a Maven project in Eclipse (you have to install the plugin and download Maven as well) and put the dependency
<dependency>
<groupId>com.github.axet</groupId>
<artifactId>vget</artifactId>
<version>1.1.23</version>
</dependency>
into your <dependencies> inside your pom.xml. After adding it, you project recognizes the additional package automatically.
Nobody tinkers by adding libraries manually. It's actually not professional to work without a build platform like Maven or Gradle.

Cant setup Elastic Search JAVA API

I have used elastic search in nodejs. But now for a java app I need elasticsearch. So I read the documentation in elastic search official website. But I cant follow one thing
I have installed Maven plugin in Eclipse.
I have done dependency setup in pom.xml in my project.
<dependencies>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.5.0</version>
</dependency>
</dependencies>
But whenever I write below line in java it says cant resolve.
import static org.elasticsearch.node.NodeBuilder.*;
So I'm unable to use elastic search in java.
I have read this as source
https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html
http://java.dzone.com/articles/elasticsearch-java-api
I am not sure what you are doing here, you shouldnt have to download the jar manually and add to eclipse as a project dependency. Please go through this tutorial to understand how maven dependency works. Relevant text below:
Maven connects to remote repositories (or you can set up your own
local repos) and automatically downloads all of the dependencies
needed to build your project. For example, lets say you have a project
that uses Apache's Camel routing tool, version 2.10.6, but a new
version of Camel is released, 2.11.1. Instead of having to go to
Apache's website, download the 2.11.1 distribution and replace 2.10.6
with it, you can just tell Maven to use the new distribution and the
work will be done for you.

Spring - Missing Required Library - hibernate3-3.2.3.GA.jar

I was following this tutorial to understand the Spring and Hibernate. After I added the hibernate dependency like this:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.3.ga</version>
</dependency>
I got this error
Project 'SpringExample' is missing required library: 'C:\Users\gmuniandy\.m2\repository\hibernate\hibernate3\3.2.3.GA\hibernate3-3.2.3.GA.jar' SpringExample Build path Build Path Problem
.
I have downloaded the jar file and placed in the folder manually but the issue still remain. Please advice.
EDIT
I guess it is an wrong writing in thy pom.xml: Instead of "ga" use "GA" as Ragu already wrote.
Did you try already the downloadable project from the Website?
And what looks strange to me, I found no hint about case-sensitivity on maven.org, though maven uses case-sensitive match when matching against property values. Referring to Maven Model
May I suggest, that you follow this tutorial?
Accessing Relational Data using JDBC with Spring
At the bottom of the Article you will see a complete pom.xml which obtains the required and correct versions of libs from a inherited pom.
It should keep your pom short and simple. So you can better concentrate on your task rather than bothering around with libs at an early stage of your project.
Have you tried to clean up your local Maven repository and resolve dependencies again?
version is wrong -correct one 3.2.3.GA , In mvn repository you can search specific jar maven dependency.

Categories

Resources