### Prerequisites

1. A [free Applitools account](/content/users/register/index.html) and Applitools API KEY

Tip: Unsure how to find your API key?

Read [Retrieving your API key](/content/docs/eyes/getting-started/retrieve-api-key/index.html) to find your API key.

2. [Java v8 or higher](https://www.java.com/en/download/help/download_options.xml)
3. [Maven](https://maven.apache.org/)

Tip: Not sure how to install?

Here are some resources:

_[Maven installation instructions](https://maven.apache.org/install.html)_

- Install with homebrew with `brew install maven`

Make sure it's in your `PATH`!

To test that it's working:

- Make sure to restart the Terminal or Command line prompt to load the new environment variables.
- Run `mvn -v`

You should see the version info for Maven.

tip

1. It's better to set APPLITOOLS\_API\_KEY as a system variable (in Windows) or in the `~/.zshrc` recipe file (in MacOS) so that it will be automatically set when you open a new terminal shell.
2. The Maven executable is inside `/bin` folder of the extracted Maven directory. **So you must include `/bin`**. It should look something like: `/Users/raja/apps/apache-maven-3.5.4/bin`

### Running the Example Project

1. Clone or download the repository and navigate to that folder

```text
git clone https://github.com/applitools/tutorial-images-java.git
cd tutorial-images-java
```

_Note: you can alternatively download the project as a Zip file and extract it_

2. Run the example test

```text
APPLITOOLS_API_KEY="[Your API Key]" mvn clean -Dtest=DemoTest test
```

### Adding Applitools Eyes to an Existing Project

1. Create a Maven project and add the following properties and dependencies to the pom.xml

```xml
  <dependencies>
    <!-- This is the Applitools Images Java SDK -->
    <dependency>
     <groupId>com.applitools</groupId>
     <artifactId>eyes-images-java5</artifactId>
     <version>RELEASE</version>
    </dependency>
  </dependencies>
```

2. Create a class with name `DemoTest.java` and add the following code

```java
package com.applitools.app;

import com.applitools.eyes.EyesRunner;
import com.applitools.eyes.TestResultsSummary;
import com.applitools.eyes.config.Configuration;
import com.applitools.eyes.images.Eyes;
import com.applitools.eyes.RectangleSize;
import com.applitools.eyes.images.ImageRunner;
import com.applitools.eyes.images.Target;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.net.URL;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.nio.file.Paths;

public class DemoTest {
    private static EyesRunner runner = new ImageRunner();
    private static Configuration config = new Configuration();

@BeforeAll
    public static void setUp(){
        //config.setServerUrl("https://eyes.applitools.com/"); //set by default
        // Define the OS and hosting application to identify the baseline.
        config.setHostOS("Windows 11");
        config.setHostApp("My App");
    }

@Test
    public void test() {

Eyes eyes = new Eyes(runner);
        eyes.setConfiguration(config);

try {
            // Start the test with a viewport size of 800x600.
            eyes.open("Demo App - Images Java", "Smoke Test - Images Java", new RectangleSize(800, 600));

// Load image.
            BufferedImage img = ImageIO.read(new URL("https://i.ibb.co/bJgzfb3/applitools.png"));

// Visual validation.
            eyes.check("Image buffer", Target.image(img));

// End visual UI testing.
            eyes.closeAsync();
        } catch(IOException ex){
            System.out.println(ex);
        } finally {
            // If the test was aborted before eyes.close was called, ends the test as aborted.
            eyes.abortIfNotClosed();
        }
    }

@AfterAll
    public static void tearDown(){
        //wait for Applitools test to finish and fetch the results
        TestResultsSummary results = runner.getAllTestResults();
        System.out.println(results);
    }
}
```

Having Trouble?

Don't suffer in silence!
Let us help you.
Please [reach out to us](https://help.applitools.com/hc/en-us/requests/new) to get your project working.

## Taking the next steps with Applitools Eyes

Congratulations on completing this quickstart!
There's still so much to learn about visual testing with Applitools, but you're off to a great start.

- [↔️ Setting match levels for visual checkpoints](/content/docs/eyes/concepts/best-practices/match-levels/index.html)
- [Organizing Tests Into Batches](/content/docs/eyes/concepts/best-practices/batching/index.html)
- [Request a demo](/content/contact/product-demo-request/index.html)
