Is there any option to install a package to my home directory (or /foo) instead of system wide ? I am looking for options using apt-get or dpkg. Something similar to --prefix in a source compile.
What I am looking for co-existing of different versions of openJDK for testing purposes.
A debian package needs to be compliant to the FHS, that clearly defines where to put data and where to install applications on any system. This clear structure makes administration easy and we all should stick to that.
In your case, when it comes to testing applications an installation to a custom directory may be desired. However there is no way to tell your package manager not to use the predefined file locations from an exisiting DEB package.
If you need an installation to another location you may need to compile your package from source, as you already pointed out. Alternatively, and if you need to use dpkg you will have to build your own private DEB where you can define other installation paths. If however the application relies on access to files located on a FHS-compliant path it may not run the way developers intended.
For installing testing versions of applications you may consider a chroot (or schroot) environment. The safest solution (though maybe overkill) for testing is installing applications in a virtual OS (e.g. through Virtual Box)