fix some compiling problems in both java and cpp