Program Packaging and Distributed Execution

    To support execution from a packaged JAR file via the command line or web interface, a program mustuse the environment obtained by StreamExecutionEnvironment.getExecutionEnvironment(). This environmentwill act as the cluster’s environment when the JAR is submitted to the command line or webinterface. If the Flink program is invoked differently than through these interfaces, theenvironment will act like a local environment.

    To package the program, simply export all involved classes as a JAR file. The JAR file’s manifestmust point to the class that contains the program’s entry point (the class with the publicmain method). The simplest way to do this is by putting the main-class entry into themanifest (such as main-class: org.apache.flinkexample.MyProgram). The main-class attribute isthe same one that is used by the Java Virtual Machine to find the main method when executing a JARfiles through the command . Most IDEs offer to include that attributeautomatically when exporting JAR files.

    The overall procedure to invoke a packaged program is as follows: