title: “Project Template for Java” nav-title: Project Template for Java nav-parent_id: start nav-pos: 0

  • This will be replaced by the TOC {:toc}

Start working on your Flink Java program in a few simple steps.

Requirements

The only requirements are working Maven 3.0.4 (or higher) and Java 8.x installations.

Create Project

Use one of the following commands to create a project:

</div>
{% unless site.is_stable %}
<p style="border-radius: 5px; padding: 5px" class="bg-danger">
    <b>Note</b>: For Maven 3.0 or higher, it is no longer possible to specify the repository (-DarchetypeCatalog) via the command line. If you wish to use the snapshot repository, you need to add a repository entry to your settings.xml. For details about this change, please refer to <a href="http://maven.apache.org/archetype/maven-archetype-plugin/archetype-repository.html">Maven official document</a>
</p>
{% endunless %}

Inspect Project

There will be a new directory in your working directory. If you've used the curl approach, the directory is called quickstart. Otherwise, it has the name of your artifactId:

{% highlight bash %} $ tree quickstart/ quickstart/ ├── pom.xml └── src └── main ├── java │   └── org │   └── myorg │   └── quickstart │   ├── BatchJob.java │   └── StreamingJob.java └── resources └── log4j.properties {% endhighlight %}

The sample project is a Maven project, which contains two classes: StreamingJob and BatchJob are the basic skeleton programs for a DataStream and DataSet program. The main method is the entry point of the program, both for in-IDE testing/execution and for proper deployments.

We recommend you import this project into your IDE to develop and test it. IntelliJ IDEA supports Maven projects out of the box. If you use Eclipse, the m2e plugin allows to import Maven projects. Some Eclipse bundles include that plugin by default, others require you to install it manually.

A note to Mac OS X users: The default JVM heapsize for Java may be too small for Flink. You have to manually increase it. In Eclipse, choose Run Configurations -> Arguments and write into the VM Arguments box: -Xmx800m. In IntelliJ IDEA recommended way to change JVM options is from the Help | Edit Custom VM Options menu. See this article for details.

Build Project

If you want to build/package your project, go to your project directory and run the ‘mvn clean package’ command. You will find a JAR file that contains your application, plus connectors and libraries that you may have added as dependencies to the application: target/<artifact-id>-<version>.jar.

Note: If you use a different class than StreamingJob as the application's main class / entry point, we recommend you change the mainClass setting in the pom.xml file accordingly. That way, the Flink can run time application from the JAR file without additionally specifying the main class.

Next Steps

Write your application!

If you are writing a streaming application and you are looking for inspiration what to write, take a look at the [Stream Application Examples]({{ site.baseurl }}/dev/stream/examples.html).

If you are writing a batch processing application and you are looking for inspiration what to write, take a look at the [Batch Application Examples]({{ site.baseurl }}/dev/batch/examples.html).

For a complete overview over the APIs, have a look at the [DataStream API]({{ site.baseurl }}/dev/datastream_api.html) and [DataSet API]({{ site.baseurl }}/dev/batch/index.html) sections.

[Here]({{ site.baseurl }}/quickstart/setup_quickstart.html) you can find out how to run an application outside the IDE on a local cluster.

If you have any trouble, ask on our Mailing List. We are happy to provide help.

{% top %}