1

So I'm using the Eclipse IDE for Java to work on exercises and store examples from my Java How to Program book. I organize them with folders for each chapter being inside the src folder, but the folders are automatically turned into packages. How can I make them just normal folders?

Folder structure

1 Answers1

0

You need to change the directory properties: Right click on the "java_how_to_program_e11" and select "Properties" for the project. In the search bar type "source" and select "Java Build P...". In the resulting "Java Build Path Properties" view ... you can remove the directories from being a "source" directory. In the same properties view, you can add the subdirectores under each of the chapters as a source directory by clicking "Add Folder".

michael shomsky
  • 130
  • 1
  • 10
  • When I do this and try to run one of the files, I get the error message "Editor does not contain a main type" –  Jun 09 '21 at 18:24
  • You'll have to add the source directories under each of the chapters. I'm guessing in each of those folders contains a /src directory with a java program that has a file with `public static void main(string args)`. Alternatively, and this may be simpler, you could add each of the chapters as its own project and not have to deal with all this hassle. To do that just import each of the "ch02,ch03,..." as a separate project. How to add a project : see the top answer here https://stackoverflow.com/questions/2636201/how-to-create-a-project-from-existing-source-in-eclipse-and-then-find-it – michael shomsky Jun 09 '21 at 18:55
  • Also, if there is no executable source file, then it's possible that the error about not containing a main type is related to code that has yet to be written. – michael shomsky Jun 09 '21 at 18:57