handle all java commands, cleanup code