Most likely the JAVA related environment is set in some startup script like /etc/profile.d/java.sh. Many applications use the /etc/profile.d directory as a place to set their own environment. The scripts inside /etc/profile.d are sourced by /etc/profile using the following piece of code
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
This mechanism is not available on all Linux distributions, anyway. If I'm not wrong, Ubuntu does not use /etc/profile.d.