How do I import new APIs in Java?
I am a beginner programmer and want to use some functionality from the API I came across on the internet, http://ini4j.sourceforge.net/ API link, it allows Java to interact with .ini files. I've downloaded an archive containing all the files needed to import, but I'm not sure how to import them into Eclipse so that I can use them with my Java project. Any help would be greatly appreciated.
source to share
The easiest way is to create a new folder under your project, for example. lib
and copy all the files of the jar
library you want to use in that folder lib
(note that you can do all this from inside eclipse)
Refresh your eclipse project to include the new files. Right click them and selectBuild Path -> Add to Build Path
You can also right click on the project and select Build Path -> Configure Build Path
source to share
I would recommend taking a look at maven. It is a tool that helps you manage your assemblies, dependencies and ...
This way, if you ever want to check out your code in the source code repository, you don't need to commit your jar files either, and it makes it easy to update your files.
Quick example:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.kanescharles.iniProject</groupId>
<artifactId>iniProject</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>iniTest</name>
<url>http://www.kanecharles.com/iniTest</url>
<build>
<finalName>iniTest</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>0.5.2</version>
</dependency>
</dependencies>
</project>
For Eclipse you have the m2eclipse plugin and if you want to search for dependencies I would recommend mvnRepository
source to share