I have unpacked my jdk in /usr/java/.
and I put CLASSPATH, PATH, JAVA_HOME into /etc/profile like below.
export JAVA_HOME=/usr/java/jdk1.7.0_21 expor
It seems that you dont have any problem with the environmental variables.
Compile your file from src with
javac a/A.java
Then, run your program as
java a.A