---
title: "Version"
description: "A version utility to canonicalize and compare GraalVM versions."
kind: "class"
id: "org.graalvm.home.Version"
module: "polyglot"
version: "25.6.0-elide.4"
canonical: "https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/home/Version.html"
---

# ◆ Version

[polyglot](../../../index.md) › [org.graalvm.home](index.md) · Every page: [llms.txt](../../../llms.txt)

Class in [`org.graalvm.home`](index.md). Since 19.3.

```java
public final class Version implements Comparable<Version>
```

Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Version`

Implements: [`Comparable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Comparable.html)`<`[`Version`](Version.md)`>`

A version utility to canonicalize and compare GraalVM versions. The GraalVM version string is not standardized and may change without notice. This class is designed to evolve with GraalVM to cover all used version formats in use. It allows to create, validate and compare GraalVM versions. Do not rely on the format of the raw version string or the result of [`toString()`](Version.md#toString%28%29), only use it to produce output for humans.

To create version instances of a particular version use the [`create(int...)`](Version.md#create%28int...%29) factory method. Use [`getCurrent()`](Version.md#getCurrent%28%29) to lookup the current GraalVM version or [`parse(String)`](Version.md#parse%28java.lang.String%29) to parse it from a raw string.

### Usage example:

This code example compares the current GraalVM version to be at least 19.3 and fails if it is not.

```java
if (Version.getCurrent().compareTo(19, 3) < 0) {
    throw new IllegalStateException("Invalid GraalVM version. Must be at least 19.3.");
}
```

Note: this class has a natural ordering that is inconsistent with equals.

**See also**

- [`HomeFinder.getVersion()`](HomeFinder.md#getVersion%28%29)

## Methods

### isRelease()
<a id="isRelease()"></a>`public boolean isRelease()`. Since 19.3. Returns `true` if this is a supported release build of GraalVM else `false`. Use this for implementation assertions that verify that only releases are deployed to production. See also: `isSnapshot()`. Cite: `org/graalvm/home/Version.html#isRelease()`

### isSnapshot()
<a id="isSnapshot()"></a>`public boolean isSnapshot()`. Since 19.3. Returns `true` if this is an unsupported snapshot build of GraalVM else `false`. Use this for implementation assertions that verify that only releases are deployed to production. See also: `isSnapshot()`. Cite: `org/graalvm/home/Version.html#isSnapshot()`

### compareTo(Version)
<a id="compareTo(org.graalvm.home.Version)"></a>`public int compareTo(Version o)`. Since 19.3. Overrides `compareTo(T)`. Cite: `org/graalvm/home/Version.html#compareTo(org.graalvm.home.Version)`

### compareTo(int...)
<a id="compareTo(int...)"></a>`public int compareTo(int... compareVersions)`. Since 19.3. Compares this version to another GraalVM version. This is equivalent to using: ` compareTo(Version.create(compareVersions)) `. Cite: `org/graalvm/home/Version.html#compareTo(int...)`

### equals(Object)
<a id="equals(java.lang.Object)"></a>`public boolean equals(Object obj)`. Since 19.3. Overrides `equals(java.lang.Object)`. Cite: `org/graalvm/home/Version.html#equals(java.lang.Object)`

### hashCode()
<a id="hashCode()"></a>`public int hashCode()`. Since 19.3. Overrides `hashCode()`. Cite: `org/graalvm/home/Version.html#hashCode()`

### toString()
<a id="toString()"></a>`public String toString()`. Since 19.3. Overrides `toString()`. Cite: `org/graalvm/home/Version.html#toString()`

### format(String)
<a id="format(java.lang.String)"></a>`public String format(String format)`. Since 23.0. Format the GraalVM version with a custom format string. The format string can contain any of the standard conversions of [`java.util.Formatter`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Formatter.html). At least four version components (possibly zero) are available as formatter arguments. In addition to the standard conversions, these special conversions are available: `"%[R...]"` includes a given part only if `isRelease`; `"%[S...]"` includes a given part only if `isSnapshot`; `"%[<digit>...]"` includes a given part only if the version contains at least `<digit>` non-zero version components (`<digit>` can be 0 to 9) Examples: Cite: `org/graalvm/home/Version.html#format(java.lang.String)`

```java
Version.parse("22.3.0.1").format("%d.%d"); // returns "22.3"
Version.parse("22.3.0.1").format("%4$d"); // returns "1"
Version.parse("22.3.0.1").format("%[R%d.%d]%[Sdev]"); // returns "22.3"
Version.parse("22.3.0.1").format("%[2XX]"); // returns "XX"
Version.parse("23.0-dev").format("%3$d"); // returns "0"
Version.parse("23.0-dev").format("%[R%d.%d]%[Sdev]"); // returns "dev"
Version.parse("23.0-dev").format("%[2XX]"); // returns ""
```

### getComponent(int)
<a id="getComponent(int)"></a>`public int getComponent(int componentIndex)`. Since 24.2. Retrieves the numeric value of the version component at the specified index. Version components are indexed as follows: `componentIndex = 0` represents the major version; `componentIndex = 1` represents the minor version; `componentIndex = 2` represents the update version If the specified `componentIndex` exceeds the number of available components, the method returns `0`. For example, a version `23.1` will return `0` for `componentIndex = 2`. Parameters: `componentIndex` `int`: the index of the version component to retrieve; must be non-negative. Throws: `IllegalArgumentException` (unchecked): if `componentIndex` is negative. See also: `Version.create(int...)`. Cite: `org/graalvm/home/Version.html#getComponent(int)`

### parse(String)
<a id="parse(java.lang.String)"></a>`public static Version parse(String versionString) throws IllegalArgumentException`. Since 19.3. Parses a GraalVM version from its String raw format. Throws [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if the passed string is not a valid GraalVM version. Cite: `org/graalvm/home/Version.html#parse(java.lang.String)`

### create(int...)
<a id="create(int...)"></a>`public static Version create(int... versions) throws IllegalArgumentException`. Since 19.3. Constructs a new GraalVM version from a list of version numbers. The versions must not be `null` and none of the version numbers must be negative. At least one version number must be non-zero. See also: `compareTo(int...)`. Cite: `org/graalvm/home/Version.html#create(int...)`

### getCurrent()
<a id="getCurrent()"></a>`public static Version getCurrent()`. Since 19.3. Returns the current GraalVM version of the installed component. Never `null`. See also: `HomeFinder.getVersion()`. Cite: `org/graalvm/home/Version.html#getCurrent()`

## Inherited members

- From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29)
