tools: libjavacore: simplify and fix script