Main Java code-Back end