There are less environment variables available when running command directly by SSH then interactively. This is because for some reason, Ubuntu does a little less for non-interactive shells and stops executing .bashrc after this line:
So if you wish to run anything, it should be done before, like:
[ -z "$PS1" ] && return
So if you wish to run anything, it should be done before, like:
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21/ [ -z "$PS1" ] && return