I want to use the Jdom package to use .XML files for my application.
I have downloaded the Jdom's build 2.0.6.
But now, I don't know how to install it.
If someone can guide me..
(I'm on macOs)
If you downloaded JDOM jar file, then simply include it to your java project in IDE.
If you use IntelliJ IDEA, then follow these steps:
File > Project Structure > Libraries > New Project Library > Java
Find your jar file
Add it to your project
If you use Maven, then you can add this code to your pom.xml:
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>2.0.2</version>
</dependency>
You can view all available versions on Maven Central.
If you use Eclipse IDE, then follow these steps :
Right click on your project > Build Path > Configure Build Path > Add external JARs
Select your JAR
Apply and save
Related
I am trying to use Dataframes in my java project. I found a library on the internet: https://github.com/cardillo/joinery. but I dont know how to add the folder to my directory and use dataframes in my project. please advise. I am new to java.
You can download the jar from here and add it to the Java project's build path.
Or if your project is maven based Java project then add the dependency in pom.xml file
<dependency>
<groupId>joinery</groupId>
<artifactId>joinery-dataframe</artifactId>
<version>1.8</version>
</dependency>
For Gradle Based Java project add in build.gradle:
dependencies{
compile "com.google.guava:guava:$guavaVersion"
}
I`m looking for the best way to convert a Java Project into a Maven Java Project.
I have a Java Project with libraries store locally and I would like to convert this project into a Maven project.
I could do that. In Eclipse a right-clicked into the project > Configure > Convert to Maven Project.
Following these steps, eclipse creates the pom.xml with artifactId, groupId, versions and etc.
I would like to know if there is any way to update the pom dependencies, for instance:
The project has a lib folder which contains all libraries/dependencies of the project, I want to update pom.xml (automatically) with these libraries so Maven can download it automatically.
Are there any way to do that automatically or you suggest to do it manually (verifying the static dependency and update the pom.xml with this dependency).
Thanks in advance.
I've got to get the HtmlUnit dependencies working by tomorrow to complete a project. I need to use java to access a webpage, fill in a form and click some buttons - HtmlUnit has been recommended for this.
I have downloaded the htmlunit 2.19 bin files which appears to have the jar dependencies and a bunch of documentation on how to use certain features - but there is no 'installation' steps.
Can someone please step me through the installation of the jar dependencies?
I am using Windows 7 and NetBeans IDE 8.0.2.
Thank in advance :)
I fixed the problem. In the libraries menu, I was just adding the folder that contained the jar files. I had to remove that and then add all the jars individually. – Joe
ref: Java: how to setup htmlunit
Right-click my project -> Properties -> Libraries -> Add JAR/Folder
Then add each jar individually.
In the downloaded htmlunit-x.y-bin.zip file, there is a lib folder, which contains all the dependencies.
or you can use maven:
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.19</version>
</dependency>
I wrote a small OpenGL library for private use.
It is based on Lwjgl. I am programming with eclipse.
Now I want to export this library to have one JarFile, which
I can add to the build path of a project and the user can
only use the library and not lwjgl. So I want to keep lwjgl and the
native files in the build path but export it with my library as one jar.
How could I achieve this?
You can consider using maven to help manage your project life cycle. While there are many other tools out there, maven has been one of the more widely used so if you encountered any difficulties, it won't be hard to find solutions.
Maven can be used to build and package your artifacts, and manage your dependencies (in this case lwjgl and other dependencies lwjgl needs). Since you are already using Eclipse, you can easily use it to create a maven project. (Refer this post here for guidance). From there, Eclipse will help to manage all your build/class paths.
Project Structure
After you create your maven project in Eclipse, you will see that under the project root folder, there is at least:
a pom.xml file. Maven uses this file to determine anything and everything about your project including dependencies.
a src/main folder. This is where you will keep all your Java source codes.
a src/test folder. This is where you will keep all your test codes.
Managing Your Dependencies
The next step involves modifying your pom.xml to specify lwjgl as a dependency. To do so, add the following dependency configuration to your pom.xml
<dependency>
<groupId>org.lwjgl.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<version>2.9.1</version>
</dependency>
Note that this <dependency> configuration should be added to a parent <dependencies> section.
This will download the main lwjgl.jar (version 2.9.1) and the natives for Windows, Linux and Mac OSX from the Maven Central Repository into your project (so you don't have to manage it manually, say in a separate lib folder).
Export Your Project As A JAR
If all went well, you will be able to build your project by navigating to your project root from command line (you can do this in Eclipse too), and issue the command
mvn clean install
which will build your Java codes, execute your unit tests suite (if any), download any dependencies specified in your pom.xml, and generate a JAR file named after your project in the target folder.
To verify, unzip the JAR file and you should be able to find lwjgl.jar along with any other dependencies in one of the folders.
Hope this will get you started.
EDIT:
Building Your Project
If your target folder remains empty after executing mvn clean install, try include this build plugin configuration in your pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>
</build>
I am learning building a Java project in Eclipse using Maven. I created a Java project HelloWorld from
“maven-archetype-quickstart” template in a folder D:/maven_projects. Then to convert the Maven project to support Eclipse IDE, I navigated into the project folder and issued the commands:
mvn eclipse:eclipse and mvn package .
Then I imported the project in Eclipse and did the necessary Eclipse configurations like setting the Maven local repository in Eclipse classpath. Now the project in D:/EclipseWorkspace folder. I ran the project successfully in Eclipse printing "helloworld".
Now if I want to go on develop the project and for that reason want to add new dependencies in pom.xml in Eclipse, then the new jars are not added in classpath when I run the project.
So my question is after importing a Maven project into Eclipse how can I add more and more dependencies in pom.xml, then build and run the project? What is the recommended and efficient way to do this?
I would recommend you don't use the m2eclipse command line tools (i.e. mvn eclipse:eclipse) and instead use the built-in Maven support, known as m2e.
Delete your project from Eclipse, then run mvn eclipse:clean on your project to remove the m2eclipse project data. Finally, with a modern version of Eclipse, just do "Import > Maven > Existing project into workspace..." and select your pom.xml.
M2e will automatically manage your dependencies and download them as required. It also supports Maven builds through a new "Run as Maven build..." interface. It's rather nifty.
1.Update project
Right Click on your project maven > update project
2.Build project
Right Click on your project again. run as > Maven build
If you have not created a “Run configuration” yet, it will open a new configuration with some auto filled values.
You can change the name. "Base directory" will be a auto filled value for you. Keep it as it is. Give maven command to ”Goals” fields.
i.e, “clean install” for building purpose
Click apply
Click run.
3.Run project on tomcat
Right Click on your project again. run as > Run-Configuration.
It will open Run-Configuration window for you.
Right Click on “Maven Build” from the right side column and Select “New”.
It will open a blank configuration for you.
Change the name as you want. For the base directory field you can choose values using 3 buttons(workspace,FileSystem,Variables). You can also copy and paste the auto generated value from previously created Run-configuration. Give the Goals as “tomcat:run”. Click apply. Click run.
If you want to get more clear idea with snapshots use the following link.
Build and Run Maven project in Eclipse
(I hope this answer will help someone come after the topic of the question)
Dependencies can be updated by using "Maven --> Update Project.." in Eclipse using m2e plugin, after pom.xml file modification.
Just install the m2e plugin for Eclipse. Then a new command in Eclipse's Import statement will be added called "Import existing maven projects".
answer 1
Right click on your project in eclipse
go to maven -> Update Project
answer 2
simply press Alt+F5
after updating your pom.xml. This will build your project again and download all jar files
Right Click on your project
Go to Maven>Update Project
Check the Force Update of Snapshots/Releases Checkbox
Click Ok
That's all. You can see progression of build in left below corner.
When you add dependency in pom.xml , do a maven clean , and then maven build , it will add the jars into you project.
You can search dependency artifacts at http://mvnrepository.com/
And if it doesn't add jars it should give you errors which will mean that it is not able to fetch the jar, that could be due to broken repository or connection problems.
Well sometimes if it is one or two jars, better download them and add to build path , but with a lot of dependencies use maven.
If you are getting this error :in cucumber Exception
Cucumber Exception: java.lang.ClassNotFoundException:
cucumber.io.ResourceLoader :
then add following jar file to your pom.xml
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.1.8</version>
</dependency>
Run the maven build once and should be gone