user2024438
user2024438

Reputation:

The import org.apache.commons cannot be resolved in eclipse juno

I am having a problem while compiling my project in Eclipse. It is showing the error The import org.apache.commons cannot be resolved.

enter image description here

Please tell me what does this error means and how to solve it.

Upvotes: 39

Views: 254579

Answers (10)

Fatma Arafa
Fatma Arafa

Reputation: 1

<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency>

add this to your pom.xml

Upvotes: -1

asgarov1
asgarov1

Reputation: 4191

For people who are working on OSGI project, you need to add the dependencies in your META-INF/MANIFEST.MF:

Import-Package:
 org.apache.commons.fileupload;version="1.3.1",
 org.apache.commons.io;version="1.4.0",
...

Upvotes: 0

Gnaneshwar Reddy
Gnaneshwar Reddy

Reputation: 1

In Provar(2.8.0), Issue got resolved after adding the jar file(commons-io-2.11.0.jar) to the project.

Steps: 1.Download the latest JAR file from https://commons.apache.org/proper/commons-io/download_io.cgi

  1. Added jar file under lib folder in project. 2.Project--> Properties --> Java build path --> Libraries--Add Jars from lib folder.

Upvotes: -1

Colonna Maurizio
Colonna Maurizio

Reputation: 97

In my little experience, I have solved the issue about org.apache.commons.cli, on my Eclipse Version: 2019-12 (4.14.0): Eclipse Project explorer

Java buid Path-->Add external Jar in the Classpath

The PATH, inside $HADOOP_HOME where is the file .jar

Upvotes: -1

ImportError
ImportError

Reputation: 375

You could also add the external jar file to the project. Go to your project-->properties-->java build path-->libraries, add external JARS. Then add your downloaded jar file.

Upvotes: 0

yTze
yTze

Reputation: 93

Look for "poi-3.17.jar"!!!

  1. Download from "https://poi.apache.org/download.html".
  2. Click the one Binary Distribution -> poi-bin-3.17-20170915.tar.gz
  3. Unzip the file download and look for this "poi-3.17.jar".

Problem solved and errors disappeared.

Upvotes: 0

Deepak Gautam
Deepak Gautam

Reputation: 1427

expand "Java Resources" and then 'Libraries' (in eclipse project). make sure that "Apache Tomcat" present.

if not follow- right click on project -> "Build Path" -> "Java Build Path" -> "Add Library" -> select "Server Runtime" -> next -> select "Apache Tomcat -> click finish

Upvotes: 5

chenlian
chenlian

Reputation: 720

If you got a Apache Maven project, it's easy to use this package in your project. Just specify it in your pom.xml:

<project>
...

    <properties>
        <version.commons-io>2.4</version.commons-io>
    </properties>

    <dependencies>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${version.commons-io}</version>
        </dependency>
    </dependencies>

...
</project>

Upvotes: 10

Olivia Liao
Olivia Liao

Reputation: 393

You could just add one needed external jar file to the project. Go to your project-->java build path-->libraries, add external JARS.Then add your downloaded file from the formal website. My default name is commons-codec-1.10.jar

Upvotes: 2

BalusC
BalusC

Reputation: 1109715

The mentioned package/classes are not present in the compiletime classpath. Basically, Java has no idea what you're talking about when you say to import this and that. It can't find them in the classpath.

It's part of Apache Commons FileUpload. Just download the JAR and drop it in /WEB-INF/lib folder of the webapp project and this error should disappear. Don't forget to do the same for Apache Commons IO, that's where FileUpload depends on, otherwise you will get the same problem during runtime.


Unrelated to the concrete problem, I see that you're using Tomcat 7, which is a Servlet 3.0 compatible container. Do you know that you can just use the new request.getPart() method to obtain the uploaded file without the need for the whole Commons FileUpload stuff? Just add @MultipartConfig annotation to the servlet class so that you can use it. See also How to upload files to server using JSP/Servlet?

Upvotes: 31

Related Questions