Core code for Java Trouble