# JVM APIs

> What Java and Kotlin programs run by Elide can use: the bundled JDK 25 and Kotlin 2.5 standard library, the libraries Elide puts on each classpath, and what is not available.

Elide compiles Java and Kotlin with its bundled `javac` and `kotlinc` and runs the program on the bundled JDK in a
separate process. The program can use the JDK, the Kotlin standard library, the libraries listed below and its own
Maven dependencies.

```kotlin
// Versions.kt
fun main() {
  println("JDK ${Runtime.version().feature()}, Kotlin ${KotlinVersion.CURRENT}")
}
```

```bash
elide run Versions.kt
```

```text
JDK 25, Kotlin 2.5.0
```

| Component | Version |
| --- | --- |
| JDK | 25 |
| Kotlin compiler and standard library | 2.5.0-Beta1 |
| [Elide annotations](https://elide.help/docs/api-jvm-annotations) (`dev.elide:elide-api`) | 1.0.0 |

## Single-file runs

`elide run Main.java` or `elide run Main.kt` outside a project compiles against this classpath:

| Language | Classpath besides the JDK |
| --- | --- |
| Java | Elide annotations |
| Kotlin | Elide annotations, Standard library, `kotlin-reflect`, kotlinx coroutines, serialization (core and JSON), datetime, io, collections-immutable, html and atomicfu |

Kotlin files compile with the kotlinx.serialization and atomicfu compiler plugins. A Kotlin file cannot import
Metro; use a project for that.

Inside a project directory (one with an `elide.pkl`, or below one), a single file also gets that project's
dependencies.

## Projects

`elide build`, `elide run` and `elide test` add these libraries to Kotlin source sets. Java source sets get only the
JUnit libraries on test sets. The switches go in `kotlin.features`, except JUnit's: `jvm.features.testing`, which
removes the bundled JUnit compile APIs and runtime when `false`; JVM test runs then need `junit-platform-console` in
`testPackages`.

| Library | Version | Main | Tests | Turn off with |
| --- | --- | --- | --- | --- |
| Elide annotations (`dev.elide:elide-api`) | 1.0.0 | Compile, run | Inherited | — |
| `kotlin-stdlib` | 2.5.0-Beta1 | Compile, run | Inherited | — |
| `kotlin-reflect` | 2.5.0-Beta1 | Compile, run | Inherited | `reflection = false` |
| `kotlinx-coroutines-core` | 1.11.0 | Compile, run | Inherited | `coroutines = false` or `kotlinx = false` |
| `kotlinx-serialization-core`, `-json` | 1.11.0 | Compile, run | Inherited | `serialization = false` or `kotlinx = false` |
| Metro runtime (`dev.zacsweers.metro:runtime`) | 1.4.5 | Compile, run | Inherited | `metro = false` |
| `kotlin-test`, `kotlin-test-junit5` | 2.5.0-Beta1 | — | Compile, run | `testing = false` |
| `kotlinx-coroutines-test` | 1.11.0 | — | Compile, run | `coroutines = false` |
| JUnit Jupiter API and params | 6.1.3 | — | Compile, run | `jvm.features.testing` |
| JUnit Jupiter engine and Platform | 6.1.3 | — | Run | `jvm.features.testing` |

A Java project adds Elide annotations as a `compileOnly` dependency; see
[Elide annotations](https://elide.help/docs/api-jvm-annotations#add-to-a-project). Other bundled libraries are linked from the binary,
without a download, when a project declares them at the bundled version; see
[Bundled libraries](https://elide.help/docs/api-jvm-libraries#other-kotlinx-libraries).

`elide classpath` prints the main classpath; `elide classpath test:compile` prints what a test set adds.

## Not available

| Not available | Detail |
| --- | --- |
| Elide runtime API | JVM programs have no `Elide` global or other runtime object; `dev.elide.annotations` is the only Elide package. |
| Calls to or from JavaScript and Python | The program runs in its own process, and `--interop` does not apply. See [Languages](https://elide.help/docs/languages). |
| OpenTelemetry | Elide injects no OpenTelemetry API, agent or trace context into JVM programs. See [OpenTelemetry](https://elide.help/docs/opentelemetry). |

## Reference

| Page | Covers |
| --- | --- |
| [Elide annotations](https://elide.help/docs/api-jvm-annotations) | Every annotation in `dev.elide.annotations`: targets, retention and effect. |
| [Bundled libraries](https://elide.help/docs/api-jvm-libraries) | kotlinx coroutines and serialization, other kotlinx libraries, Metro, JUnit and `kotlin.test`. |
| [Insight for JVM programs](https://elide.help/docs/api-jvm-insight) | `--insights` scripts and classes on a JVM project run. |

## Samples

- [Kotlin coroutines](https://elide.help/docs/code-samples#kotlin-coroutines)
- [Kotlin JSON serialization](https://elide.help/docs/code-samples#kotlin-json-serialization)
- [Java with a Maven dependency](https://elide.help/docs/code-samples#java-with-a-maven-dependency)
- [Elide annotations in Kotlin](https://elide.help/docs/code-samples#elide-annotations-in-kotlin)
