push_pin

Note

Prefer to read code directly? Take a look at the corresponding example project on GitHub.

Jeamlit Embedded

This method embeds Jeamlit as a dependency in your existing Maven or Gradle project. This method is best for complex apps, existing systems, and production deployments.

This page will walk you through adding Jeamlit to your Maven or Gradle project, creating a simple interactive app, and launching an embedded server. You'll build the same click counter app but with full control over the server lifecycle.

As with any Java project, you'll need:

  1. Java JDK >= 21

    Download and install a Java JDK (we recommend Eclipse Adoptium).

    You can verify your Java installation by running:

    java --version
  2. Maven or Gradle

    • Maven: Download from maven.apache.org or use the Maven wrapper (mvnw) included in most projects
    • Gradle: Download from gradle.org or use the Gradle wrapper (gradlew)
  3. An IDE (recommended)

    We recommend IntelliJ IDEA for the best hot-reload experience with Jeamlit.

  1. Add the Jeamlit dependency to your pom.xml:

    <dependencies> <dependency> <groupId>io.jeamlit</groupId> <artifactId>jeamlit</artifactId> <version>0.44.0</version> </dependency> <!-- Optional: Add any other dependencies your app needs --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-math3</artifactId> <version>3.6.1</version> </dependency> <!-- Recommended: Add a logging implementation if you don't have one already --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.5.18</version> </dependency> </dependencies>
  2. Make sure your pom.xml specifies Java 21:

    <properties> <maven.compiler.source>21</maven.compiler.source> <maven.compiler.target>21</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
  1. Add the Jeamlit dependency to your build.gradle:

    dependencies { implementation 'io.jeamlit:jeamlit:0.44.0' // Optional: Add any other dependencies your app needs implementation 'org.apache.commons:commons-math3:3.6.1' // Recommended: Add a logging implementation implementation 'ch.qos.logback:logback-classic:1.5.18' }
  2. Make sure your build.gradle specifies Java >= 21:

    java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }
  1. Create src/main/java/App.java with your Jeamlit application:
import io.jeamlit.core.Jt; import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; public class App { public static void main(String[] args) { Jt.title("Hello World !").use(); Jt.markdown("## A simple click app").use(); // initialize state - values in the session state are maintained at each update Jt.sessionState().putIfAbsent("count", 0); // if button is clicked, increment the count value if (Jt.button("Click me").use()) { Jt.sessionState().computeIfPresentInt("count", (k, v) -> v + 1); } // display the count int count = Jt.sessionState().getInt("count"); boolean plural = count > 1; Jt.markdown("The button was clicked **%s** time%s".formatted(count, plural ? "s" : "")) .use(); // Use the imported library apache commons-math Jt.divider().use(); Jt.markdown("## Using imported apache math dependency").use(); double[] values = {1.2, 2.3, 3.4, 4.5, 5.6}; DescriptiveStatistics stats = new DescriptiveStatistics(values); double stdDev = stats.getStandardDeviation(); Jt.text("Computed statistic with Apache commons-math: " + stdDev).use(); } }
  1. Create src/main/java/Launcher.java to start the embedded server:
import io.jeamlit.core.Server; public class Launcher { public static void main(String[] args) { final var server = Server.builder(App.class, 8080).build(); server.start(); } }
  1. Build your project:

    ./mvnw clean install
  2. Run the Jeamlit server:

    ./mvnw compile exec:java -Dexec.mainClass="Launcher"
  3. Open your browser at http://localhost:8080 to see your app!

  4. To stop the server, press Ctrl+C in the terminal.

  1. Build your project:

    ./gradlew build
  2. Run the Jeamlit server:

    ./gradlew run --main-class=Launcher
  3. Open your browser at http://localhost:8080 to see your app!

  4. To stop the server, press Ctrl+C in the terminal.

  1. Open your project in IntelliJ IDEA
  2. Run Launcher.java in Debug mode (not Run mode)
  3. Open your browser at http://localhost:8080
  4. Edit App.java and add some code, for example:
    Jt.markdown("**OMG THE HOT-RELOAD IS REAL**").use();
  5. When you see the "Code Change" modal in IntelliJ, click it to hot-reload
  6. Refresh your browser to see the changes instantly!

Read about our Basic concepts to understand Jeamlit's dataflow model

forum

Still have questions?

Go to our discussions forum for helpful information and advice from Jeamlit experts.