Google App Script Authorization error for Java

I was able to send a string from App Script to Java Application using
a single function. For instance:

function returnText() {
  return "Hello"; 
}

Java application is able to print the string to a command line.

However, when I add multiple functions to Google App Script, I get an
authorization error. Please see the error below:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 401
Unauthorized

How can I solve this problem?