app_java: detect JAVA_HOME and use proper libgcj versioning

(cherry picked from commit 5c1b8e0f0f5565aa69440a331c520fc549856092)