Java hangs