Import org.apache.Commons.io.input library from Java to Eclipse

Asked

Viewed 697 times

0

I need to use the class Reversedlinesfilereader, which belongs to the org.apache.Commons.io.input library.

@Tommelo told me that I should include a dependency of this library in the archive pom.xml from Maven. This is the dependency: mvnrepository.com/Artifact/Commons-io/2.5

I copied and pasted the dependency into the file pom.xml, in a blank space, exactly as she was:

<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.5</version>
</dependency

That’s right, I shouldn’t include any code before entering the dependency?

The other question is, how do I care about my Java class that I’m writing in a Java Project in Eclipse? I tried: import org.apache.Commons.io.input; but Eclipse does not recognize org.apache, even though I already included the dependency in Pow.xml.

Where is the error?

  • 2

    Turn your project into a Maven project. You can by right-clicking on the project, there by the last options will appear something of nature (has a submenu), then you ask to turn into Maven project

  • 2

    And that’s the fun of the Maven dependencies, you just have to declare that you will use them, you don’t need much else in pom.xml

1 answer

0

Well, according to user Jefferson Quesado, so that the dependencies declared on pom.xml be seen by my project in Eclipse, this project needs to be a "Java Project, but of the type Maven" which is a library manager that comes along with Eclipse. In Eclipse itself I can transform my Java project into a Maven. Or create from the beginning the project as Maven.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.