I have com.company.database.mysql and com.company.database.sqlite. I only want to include com.company.database.mysql.
My code was organized in folders (eg com/company/database/mysql) but now I want to have it flattened (eg com.company.database.mysql) so that I can include just the mysql code.
Eclipse doesn’t seem to let me do this. It complains that the package is wrong “The declared package “com.company.database.mysql” does not match the expected package “” It only works if I unflatten it (ie com/company/database/mysql).
How can I get eclipse to work with code in folders named com.company.etc instead of subfolders?
The problem is that the Java compiler interprets periods in package declarations to be separate directories. So, if your file
DataAccess.javais like:The compiler will insist that this file be in a directory named
mysqlwhich is in a directory namedatabasewhich is … In other words your original directory structure:That is the reason for the error. However you don’t have to go to the lengths that you are just to exclude some of the source. You can manage your project’s source path (Project properties > Build path) and exclude one or more directories.