I’ve got 45 java packages I’ve imported into a src folder in Eclipse. Each of course has a particular name, and contains numerous java files. Problem is that the import statements in the packages’ classes all refer to the various packages (including themselves in the package line) with an initial prefix name.
So for example, if the package name is
snowman.image
the java files within start with abc.snowman.image
and refer to another package named snowball.hit as abc.snowball.hit. Needless to say, Eclipse complains that these packages referred to in the code do not exist.
I’m thinking I must’ve done something wrong. Did I import the packages incorrectly? Can I change some property so that the prefix is understood before the packages’ names. I’d rather not go through hundreds of java files and manually change the package and import names.
First you need to make sure that the project configuration is correct. Right click on the project, then go to “properties”, and in the tree on the left select “java build path”. Switch to the “source” tab and and make sure then you have the “your project/src” as a source folder. Starting from the “src” folder you will have the package names just as Tom commented on your question.
Also eclipse has some nice feature, such as “organize imports” – default shortcut ctrl+shift+o – which will look through your source files and update your imports. This works both in the text editor for the current class, as also from the “navigator/package explorer” view for the entire. selected project.
Please make a backup of your project before trying this, as it will automatically change your files by removing unused and adding the imports it finds in your current structure so you might end up with
snowball.hitinstead of your desiredabc.snowball.hit.