Modified the java codes