Improvement on java handling