TennSeven TennSeven - 2 months ago 7
Java Question

How do I fix a "declared package does not match the expected package" error on Eclipse?

I've feel like I have gone through the proper steps to fix this error, and I've looked at other questions about this in SO and other places, but for some reason I'm still having an issue.

I am trying to set up a project using the Apache JMeter source code.

As an example, the file

BeanShellAssertion.java
is in

~/workspace/apache-jmeter-2.9/src/components/org/apache/jmeter/assertions.


My source folder is
src/components
. The package declaration in
BeanShellAssertion.java
is

package org.apache.jmeter.assertions;


Looking at it, it seems like everything is set up the way it is supposed to be. However, the package declaration is causing an error:

The declared package "org.apache.jmeter.assertions" does not match the
expected package "components.org.apache.jmeter.assertions"


Image is below. What exactly am I doing wrong here?

enter image description here

enter image description here

Answer

put your src/components/ to source path

right click > properties > java build path > source > add folder > select src/components