# Java and Kotlin with Elide

> Run, compile, format, build, and test Java and Kotlin with Elide's built-in JDK 25 and Kotlin toolchain

Elide compiles, formats, builds, and tests Java (up to JDK 25) and Kotlin (2.5.0-Beta1), and resolves Maven
dependencies.

## Run a source file

A file with a `main` entrypoint compiles and runs directly:

```bash
elide run Hello.java
elide run Hello.kt
```

## Use individual tools

`elide java`, `elide javac`, `elide kotlinc`, and `elide jar` behave like the tools of the same name. Pass their
arguments after `--`:

```bash
elide javac -- -d target src/main/java/app/Main.java
elide kotlinc -- -d target src/main/kotlin/app/Main.kt
elide java -- -cp target app.Main
```

`elide format` formats Java with Google Java Format and Kotlin with ktfmt:

```bash
elide format -- src                          # rewrite files
elide format --list-files -- --dry-run src   # list files that would change; exit 1 if any
```

## Start a project

```bash
elide init --plain --skip-defaults --template java
```

| Template | Creates |
| --- | --- |
| `java` | A Java project. |
| `ktjvm` | A Kotlin project. |
| `workspace` | A Kotlin library and an app that depends on it. |

For an existing Maven or Gradle project, `elide adopt` runs an AI coding agent to do the migration; see
[Adopt an Existing Project](https://elide.help/docs/toolchain/usage/adopt).

## Build a project

```bash
elide install   # resolve Maven dependencies
elide build     # compile and assemble artifacts
elide test      # run JUnit tests
elide run       # run the project's main class
```

<img src="https://elide.help/assets/demos/project-build.gif" alt="Elide projects — build, run, and reuse cached work" width="1591" height="910" loading="lazy" decoding="async" class="rounded-lg border border-border my-6 w-full" />

`elide build --inspect` lists the project's task names. See [Elide Projects](https://elide.help/docs/projects) for the manifest and
[JVM Toolchain](https://elide.help/docs/toolchain/jvm) for compiler and packaging options.
