I have java two projects; one server project and one client project. In my network code between the two, I send requests. I don't want to type 0, 1, 2 for the different types of requests in the code, so I use constants instead. My problem is that I don't want to declare these constants in both projects, but rather at one place, since the constants are the same for both projects. Does anyone know a good solution for this?
Edit: The client project is an android application and the server is a servlet which should handle requests from clients.
Create a library project with an Interface. This interface declares the constants. Share this library in both projects. If you use some dependency management as in maven this is quite easy.
EDIT:
Using a final Class as described in http://en.wikipedia.org/wiki/Constant_interface is better! But the core is, to use a library project and share the common part of both projects in a separate jar.