 <blockquote> <p>the error messages are "expected illegal start of type" on writeUTF method.</p> </blockquote> <p>The problem is that you have put statements into a class body.</p> <p>The those statements need to go into a method. Your text book or tutorial should explain this.</p>