Makefile: fix JAVA_HOME detection

Use readlink and sed to detect JAVA_HOME and also fix CXXFLAGS.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Merge pull request #5 from yegorich/java-home

Makefile: fix JAVA_HOME detection