It is the Java problem but not the eclipse problem.
From 7.2.1 Storing Packages in a File System in The Java Language Specification:
Under this simple organization of packages, an implementation of the
Java platform would transform a package name into a pathname by
concatenating the components of the package name, placing a file name
separator (directory indicator) between adjacent components.
For example, if this simple organization were used on a UNIX system,
where the file name separator is /, the package name:
jag.scrabble.board
would be transformed into the directory name:
jag/scrabble/board
and:
com.sun.sunsoft.DOE
would be transformed to the directory name:
com/sun/sunsoft/DOE
Your packages name should match the file pathname .So you should change Class A
's package from package com.stackoverflow.hierarchy
to package com.hierarchy
or put the Class A
into the folder /MyProject/src/com/stackoverflow/hierarchy