Working on java but not in js