You must be careful, however, because not every Java
platform is free. Sun continues distributing an executable
Java platform which is nonfree, and other companies do so
too.
The free environment for Java is called IcedTea; the
source code Sun freed is included in that. So that is the
one you should use. Many GNU/Linux distributions come with
IcedTea, but some include nonfree Java platforms.
To reliably ensure your Java programs run fine in a free
environment, you need to develop them using IcedTea.
Theoretically the Java platforms should be compatible, but
they are not compatible 100 percent.