title: Apache Flink: The RemoteEnvironment cannot be instantiated when running in a pre-defined context
body: <p>Does any one know, what is the root of the following error while running a program on a remote Flink cluster?      </p>
  
  <p>How can I resolve it?</p>
  
  <pre><code> org.apache.flink.client.program.ProgramInvocationException: The main method caused an error.
      at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:512)
      at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:395)
      at org.apache.flink.client.program.Client.runBlocking(Client.java:252)
      at org.apache.flink.client.CliFrontend.executeProgramBlocking(CliFrontend.java:675)
      at org.apache.flink.client.CliFrontend.run(CliFrontend.java:326)
      at org.apache.flink.client.CliFrontend.parseParameters(CliFrontend.java:977)
      at org.apache.flink.client.CliFrontend.main(CliFrontend.java:1027)
  Caused by: org.apache.flink.api.common.InvalidProgramException: The RemoteEnvironment cannot be instantiated when running in a pre-defined context (such as Command Line Client, Scala Shell, or TestEnvironment)
      at org.apache.flink.api.java.RemoteEnvironment.&lt;init&gt;(RemoteEnvironment.java:118)
      at org.apache.flink.api.java.RemoteEnvironment.&lt;init&gt;(RemoteEnvironment.java:78)
      at org.apache.flink.api.java.ExecutionEnvironment.createRemoteEnvironment(ExecutionEnvironment.java:1155)
      at org.apache.flink.test.myProj.main(myProj.java:133)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:497)
      ... 6 more
  </code></pre>