# Project Template for Java 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**: * [Use **Maven archetypes**](#maven-archetype) * [Run the **quickstart script**](#quickstart-script)
``` $ mvn archetype:generate \ -DarchetypeGroupId=org.apache.flink \ -DarchetypeArtifactId=flink-quickstart-java \ -DarchetypeVersion=1.7.1 ```
This allows you to **name your newly created project**. It will interactively ask you for the groupId, artifactId, and package name.
``` $ curl https://flink.apache.org/q/quickstart.sh | bash -s 1.7.1 ```
## 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`:
``` $ tree quickstart/ quickstart/ ├── pom.xml └── src └── main ├── java │   └── org │   └── myorg │   └── quickstart │   ├── BatchJob.java │   └── StreamingJob.java └── resources └── log4j.properties ```
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](http://www.eclipse.org/m2e/) allows to [import Maven projects](http://books.sonatype.com/m2eclipse-book/reference/creating-sect-importing-projects.html#fig-creating-import). 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](https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties) 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 Processing Application Tutorial](//ci.apache.org/projects/flink/flink-docs-release-1.7/tutorials/datastream_api.html#writing-a-flink-program). 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](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/batch/examples.html). For a complete overview over the APIs, have a look at the [DataStream API](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/datastream_api.html) and [DataSet API](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/batch/index.html) sections. [Here](//ci.apache.org/projects/flink/flink-docs-release-1.7/tutorials/local_setup.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](http://mail-archives.apache.org/mod_mbox/flink-user/). We are happy to provide help.