To date, I have always coded using a text editor, and compiling using CLI (Windows and Mac). This is the first time I’ve used an IDE, and I have chosen NetBeans. It is also the first time I have come across packages.
Would appreciate some guidance/direction on how to setup my project.
My project consists of:
– a Server app
– a Client app
– common objects
This is what I have done:
- Create a Project
- Under this project, I created three packages:
- Server – source files specific only to my Server application
- Client – source files specific only to my Client application
- Common – common files shared by both Server and Client applications, such as RMISSLClientSocketFactory, remote interface and implementation, keystore files etc
Is this the right approach?
And also, what do I need to do to enable the Server all and Client app can call/access the classes in the Common package?
Many thanks in advance.
General convention would suggestion your top level package name should be the reverse of you companies web address (ie
com.stackoverflow).Now not everybody has a company (or web address), in these cases you want to choice something that will (as well as possible) uniquely identify you package (the purpose of packages is to provide name space, so you can have more the one class with the same name and be able to differentiate between them, amongst other things).
In may case I might choose to use
mad.programmerfor example…The next level should identify the application or library (I personally use things like
.coreand.core.uifor my core libraries, but you can make you own choices)At this point, you’re basically free to group as you see fit.
Now, to the question at hand.
In your case, I would create three projects. One being for the server code, one being for the client code and one for you common classes (which would be shared between the server and client).
I would link the common project to your server and client projects (right click the
Librariesnode of the project (client and/or server) and selectAdd Project).Personally, I would use the
.client,.server,.commonsuffixes to you package names just to separate the code but the only really requirement is to provide your common library with it’s own name space, separate from the server and client.So long as you haven’t changed any code that the sever and client rely-on to communicate (objects that might be passed between them at runtime), you can rebuild either project without affecting the other.
That’s my take on it any way.