It's said that a java package may contain classes, interfaces, enums, ... but I've been seeking over the net and I still haven't found what I'm looking for ... When I see package info files they also include classes... My idea is that package defines classes, interfaces, etc. in the same file but the code of the class should be in a separate class file, shouldn't it?
Should I name the same package in each class I create for Eclipse to put them all together under the same package without the need of a package info file? On the other hand, is really necessary that Eclipse creates a treedir for each package? Could I just define at a package file where the classes are located? What would be the content to a package info file?
It's also said that when you're going to use a package it should be in a .jar format... is it true?
What I'm trying to do is building a common custom package for using it in several projects, but I want to have it linked instead of copied to each project so I modify the code only once... is this possible in Eclipse?
Idea 1: + a packagefile with all definitions and location of classes + a bunch of clases spread by theme in different folders + eclipse will work with a linked package file creating a package in the folder tree that contains the classes referenced in the package.
Idea 2: + no packagefile + each class will say which packge is in by including the package name + eclipse will work with a linked bunch of classes that references the same package, so that's what it creates in the project tree.
Update 20180904:
I would like to store all my classes in a separate folder like ".../classes/*.java"
I plan to link some of those classes under a package as Eclipse environment allows, say ".../src/com.dataproc/class1.java ..."
I would like to compile the package and get it ready for the project I'm developing and for other projects in a special directory, say ".../mylib/common/*.jar
When I say "at the same time" it's because I want to work in the same environment creating the classes for my package and my project.
As you may think, I'm still a rookie with java and Eclipse, but hey, eager to learn! I have to say I reviewed the mentioned Oracle info about packages but I still don't have a clear idea of how to proceed. It's too basic for me so I don't understand if I have to declare the package inside every class java file or declare all the classes I want inside some package-info.java file, what I do know is that I have to use "import mypackagename.*" inside my project...
Any help or orientation is really appreciated.
Update 20180926: This question has been solved from this related question