[java] Using FileUtils in eclipse

When trying to use FileUtils I get "cannot be resolved" error.

enter image description here

Then, how do I install FileUtils library to be able to use it in Eclipse? I see it is an Ant utility, but I am not sure how many jars I need to install.

enter image description here

This question is related to java ant jar fileutils

The answer is


Open the project's properties---> Java Build Path ---> Libraries tab ---> Add External Jars

will allow you to add jars.

You need to download commonsIO from here.


<!-- https://mvnrepository.com/artifact/org.apache.directory.studio/org.apache.commons.io -->
<dependency>
    <groupId>org.apache.directory.studio</groupId>
    <artifactId>org.apache.commons.io</artifactId>
    <version>2.4</version>
</dependency>

Add above dependency in pom.xml file


FileUtils is class from apache org.apache.commons.io package, you need to download org.apache.commons.io.jar and then configure that jar file in your class path.


For selenium automation users

  1. Download Library file from http://www.java2s.com/Code/Jar/o/Downloadorgapachecommonsiojar.htm
  2. Extract
  3. Right click on the proj name from the explorer >> Build path >>Config Build Path

I have come accross the above issue. I have solved it as below. Its working fine for me.

  1. Download the 'org.apache.commons.io.jar' file on navigating to [org.apache.commons.io.FileUtils] [ http://www.java2s.com/Code/Jar/o/Downloadorgapachecommonsiojar.htm ]

  2. Extract the downloaded zip file to a specified folder.

  3. Update the project properties by using below navigation Right click on project>Select Properties>Select Java Build Path> Click Libraries tab>Click Add External Class Folder button>Select the folder where zip file is extracted for org.apache.commons.io.FileUtils.zip file.

  4. Now access the File Utils.


Now selenium supports following code:

FileHandler.copy(src, dest);

Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to ant

How to create a signed APK file using Cordova command line interface? This compilation unit is not on the build path of a Java project Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova How to execute Ant build in command line adding comment in .properties files Ant if else condition? Using FileUtils in eclipse How to put a jar in classpath in Eclipse? JAVA_HOME does not point to the JDK How to set ANT_HOME with Windows?

Examples related to jar

Running JAR file on Windows 10 Add jars to a Spark Job - spark-submit Deploying Maven project throws java.util.zip.ZipException: invalid LOC header (bad signature) java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonFactory Maven Error: Could not find or load main class Where can I download mysql jdbc jar from? Access restriction: The type 'Application' is not API (restriction on required library rt.jar) Create aar file in Android Studio Checking Maven Version Creating runnable JAR with Gradle

Examples related to fileutils

Using FileUtils in eclipse