IDE Guides

- Instructions for IntelliJ IDEA
- Instructions for Eclipse

About Maven

Maven is a build automation tool used primarily for Java projects. It addresses two aspects of building software: First, it describes how software is built, and second, it describes its dependencies.

Maven projects are configured using a Project Object Model, which is stored in a pom.xml-file.
Here’s a minimal example:

<project>
    <!-- model version - always 4.0.0 for Maven 2.x POMs -->
    <modelVersion>4.0.0</modelVersion>

    <!-- project coordinates - values which uniquely identify this project -->
    <groupId>com.mygroup</groupId>
    <artifactId>my-javalin-project</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <!-- library dependencies -->
    <dependencies>
        <dependency>
            <groupId>io.javalin</groupId>
            <artifactId>javalin</artifactId>
            <version>1.2.0</version>
        </dependency>
    </dependencies>
</project>

Instructions for IntelliJ IDEA

  • Click File and select New project...
  • Select Maven on the left hand menu and click Next
  • Enter GroupId, ArtifactId and Version, and click Next
  • Give your project a name and click Finish:
  • Paste the Javalin dependency into the generated pom.xml. If prompted, tell IntelliJ to enable auto-import.
<dependencies>
    <dependency>
        <groupId>io.javalin</groupId>
        <artifactId>javalin</artifactId>
        <version>1.2.0</version>
    </dependency>
</dependencies>

Finally, paste the Javalin “Hello World” snippet into a new file, Main.java:

  • Java
  • Kotlin
import io.javalin.Javalin;

public class HelloWorld {
    public static void main(String[] args) {
        Javalin app = Javalin.start(7000);
        app.get("/", ctx -> ctx.result("Hello World"));
    }
}
import io.javalin.Javalin

fun main(args: Array<String>) {
    val app = Javalin.start(7000)
    app.get("/") { ctx -> ctx.result("Hello World") }
}

Now everything is ready for you to run your main Class. Enjoy!

If IntelliJ says Method references are not supported at this language level, press alt + enter
and choose Set language level to 8 - Lambdas, type annotations, etc.*

Instructions for Eclipse

  • Click File and select New then Other...
  • Expand Maven and select Maven Project, then click Next
  • Check the Create a simple project checkbox and click Next
  • Enter GroupId, ArtifactId, Verison, and Name, and click Finish
  • Open the pom.xml file and click the pom.xml tab. Paste the Javalin dependency
<dependencies>
    <dependency>
        <groupId>io.javalin</groupId>
        <artifactId>javalin</artifactId>
        <version>1.2.0</version>
    </dependency>
</dependencies>

Finally, paste the Javalin “Hello World” snippet into a new file, Main.java:

  • Java
  • Kotlin
import io.javalin.Javalin;

public class HelloWorld {
    public static void main(String[] args) {
        Javalin app = Javalin.start(7000);
        app.get("/", ctx -> ctx.result("Hello World"));
    }
}
import io.javalin.Javalin

fun main(args: Array<String>) {
    val app = Javalin.start(7000)
    app.get("/") { ctx -> ctx.result("Hello World") }
}

Now everything is ready for you to run your main Class. Enjoy!