Reputation: 831
I'm trying to add apache-commons to my fresh project but I got problems with packages after importing the source.
The declared package "org.apache.commons.math" does not match
the expected package "src.main.java.org.apache.commons.math"
What can I do?
Upvotes: 2
Views: 19125
Reputation: 20003
Packages in Java translate into a folder hierarchy, both for the source files and the compiled class files. A Source Folder expected to contain the package org.apache.commons.math
will contain files in a structure like org/apache/commons/math/
where the Source Folder is the direct parent of org
. Having an expected package of src.main.java.org.apache.commons.math
means that src/main/java
is in a Source Folder rather that being set as a Source Folder. Open your project's Properties dialog, go to the Java Build Path page, and correct the contents of the Source tab. If you're using Maven or another tool to compile your sources instead, fix that configuration directly.
Upvotes: 3