Apache commons io java как включить
Перейти к содержимому

Apache commons io java как включить

  • автор:

Apache Commons IO — Environment Setup

In this chapter, we will learn about the local environment setup of Apache Commons IO and how to set up the path of Commons IO for Windows 2000/XP, Windows 95/98/ME etc. We will also understand about some popular java editors and how to download Commons IO archive.

Local Environment Setup

System Requirements

JDK Java SE 2 JDK 1.8 or above
Memory 1 GB RAM (recommended)
Disk Space No minimum requirement
Operating System Version Windows XP or above, Linux

Verify your Java Installation

First of all, you need to have Java Software Development Kit (SDK) installed on your system. To verify this, execute any of the two commands depending on the platform you are working on.

If the Java installation has been done properly, then it will display the current version and specification of your Java installation. A sample output is given in the following table.

Open command console and type −

\>java -version

java version «11.0.11» 2021-04-20 LTS

Java(TM) SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194)

Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode)

Open command terminal and type −

$java -version

java version «11.0.11» 2021-04-20 LTS

Open JDK Runtime Environment 18.9 (build 11.0.11+9-LTS-194)

Open JDK 64-Bit Server VM (build 11.0.11+9-LTS-194, mixed mode)

We assume the readers of this tutorial have Java SDK version 11.0.11 installed on their system.

In case you do not have Java SDK, download its current version from www.oracle.com/technetwork/java/javase/downloads/index.html and have it installed.

Set your Java Environment

Set the environment variable JAVA_HOME to point to the base directory location where Java is installed on your machine. For example,

Set JAVA_HOME to C:\ProgramFiles\java\jdk11.0.11

Export JAVA_HOME = /usr/local/java-current

Append the full path of Java compiler location to the System Path.

Append the String «C:\Program Files\Java\jdk11.0.11\bin» to the end of the system variable PATH.

Export PATH = $PATH:$JAVA_HOME/bin/

Execute the command java -version from the command prompt as explained above.

Popular Java Editors

To write your Java programs, you need a text editor. There are many sophisticated integrated development environment (IDEs) available in the market. But for now, you can consider one of the following −

Notepad − On Windows machine you can use any simple text editor like Notepad (Recommended for this tutorial), TextPad.

How To Install Java Artifact commons-io.commons-io v2.11.0

How To Install Java Artifact commons-io.commons-io In Version 2.11.0

To install the Apache Commons IO artifact in version 2.11.0 add the following dependency to your pom.xml file for Maven Project.

The dependency needs to be added in the dependencies section which is located in the main project tag of the pom.xml file. The sample pom.xml file that uses Apache Commons IO dependency could look as follows:

Other dependency snippets for Gradle, SBT, Ivy, Grape, Leiningen, and Buildr

Below you can find code snippets for other project build tools like Gradle, SBT, Ivy, Grape, Leiningen, and Buildr.

Java How To Install Apache Commons IO

You’ve probably seen code examples where people import libraries from Apache Commons IO. There exists a number of useful utilities that come with this library. These can make your life easier.

NOTE — We are doing this without Maven and without an IDE. If you use either of those things your experience might be different.

There are three main steps to installing Apache Commons IO:

  • Download
  • Add to your CLASSPATH
  • import in your program

If you don’t have it installed and setup on the CLASSPATH properly you might see an error like the following:

You can download Apache Commons IO library as binary or source HERE.

We’re going to show you how to download and install this on Linux. The steps should be almost the same for Mac OSX or Windows. The paths might be a bit different.

First create a directory to keep your libraries in. Then download the file using wget and unpack it.

Next Setup the CLASSPATH. You can set this up and verify it with the following commands. This will be effective immediately.

If you want the CLASSPATH to remain setup after you leave the current terminal you will want to add the command from above to your .bashrc file like this.

Next you are going to want to test this out. Create a Java source file that imports everythings from org.apache.commons.io and test one of the methods. Here is a code example showing how you might do this.

Once you’ve setup your source file try building it with javac. If everything was done correctly it should compile with no errors.

How to include Apache Commons IO in Eclipse? (Java)

How can I configure my Eclipse installation to use classes from Apache Commons IO?

I want to use this code:

But it gives the error:

Peter Mortensen's user avatar

3 Answers 3

What you need to do is this: How to import a jar in Eclipse add jar

Mike Q's user avatar

You also can use build tools eclipse plugins like m2eclipse or IAM (formerly Q4e).

IAM can be be installed following those instructions, and ha s a great dependency viewer

Differences between m2eclipse and IAM are discussed here, there and here.

Q4E is event-oriented, I believe that m2e uses the console and stdin/out.

A bigger one is that m2eclipse forks and uses an external maven (for running maven goals) while iam/q4e only uses the embedder.
Our position here is that it is the way to go, allowing deep integration and better performance.
It certainly has allowed us to quickly do things like the dependency analysis view and some other "magic" in the maven incremental builder.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *