# GraalVM Environment
An environment providing the Graal Java Virtual Machine
This notebook creates a **[reusable environment](https://nextjournal.com/nextjournal/environments)** with the [Graal JVM](https://graalvm.org/).
Nextjournal uses the the Graal JVM [Community Edition](https://github.com/graalvm/graalvm-ce-builds/). Note that the GraalVM version and installation directory are set as environment variables on the runtime.
[reference][nextjournal#reference#57e139fb-1a5e-43c3-b551-c1546ecb95b5]
Download the install tarfile.
```bash id=22f34710-72c9-46d3-bc78-b80130eec66c
file="graalvm-ce-java${JAVA_VERSION}-linux-amd64-${GRAAL_VERSION}.tar.gz"
path="graalvm/graalvm-ce-builds/releases/download/vm-${GRAAL_VERSION}/${file}"
url="https://github.com/${path}"
wget --progress=bar:force -P /results $url
```
[graalvm-ce-java11-linux-amd64-21.0.0.2.tar.gz][nextjournal#output#22f34710-72c9-46d3-bc78-b80130eec66c#graalvm-ce-java11-linux-amd64-21.0.0.2.tar.gz]
Extract to the installation dir.
```bash id=351460f8-8f6a-4327-8348-717f8bda3b6f
mkdir $GRAAL_DIR
tar -zxf [reference][nextjournal#reference#41b70c77-24a6-4a5e-b7c3-75b0dd080210] \
-C $GRAAL_DIR --strip-components=1
```
And test.
```bash id=ddb404a8-852e-4539-b9fc-4910c9fc82c3
java -version
```
Install the Native Image executable.
```bash id=b08d71a1-411b-4850-b675-89479cd22b28
gu install native-image
```
[nextjournal#reference#57e139fb-1a5e-43c3-b551-c1546ecb95b5]:
<#nextjournal#reference#57e139fb-1a5e-43c3-b551-c1546ecb95b5>
[nextjournal#output#22f34710-72c9-46d3-bc78-b80130eec66c#graalvm-ce-java11-linux-amd64-21.0.0.2.tar.gz]:
[nextjournal#reference#41b70c77-24a6-4a5e-b7c3-75b0dd080210]:
<#nextjournal#reference#41b70c77-24a6-4a5e-b7c3-75b0dd080210>
This notebook was exported from https://nextjournal.com/a/KZc7LfYCW95NrWjPQ5Tm1?change-id=CvBejwDGLHFDocotXeTM6g
```edn nextjournal-metadata
{:article
{:settings {:numbered? true, :sidebar? true, :subtitle? true},
:nodes
{"22f34710-72c9-46d3-bc78-b80130eec66c"
{:compute-ref #uuid "4e744a33-24ba-41e9-8497-f5d3e2649275",
:exec-duration 5487,
:id "22f34710-72c9-46d3-bc78-b80130eec66c",
:kind "code",
:locked? false,
:output-log-lines {:stdout 17},
:runtime [:runtime "4641de4c-67e7-4689-90f8-f22f1092707a"]},
"351460f8-8f6a-4327-8348-717f8bda3b6f"
{:compute-ref #uuid "93623bcd-fdc7-41ee-a5cb-503c14a22131",
:exec-duration 13869,
:id "351460f8-8f6a-4327-8348-717f8bda3b6f",
:kind "code",
:output-log-lines {},
:runtime [:runtime "4641de4c-67e7-4689-90f8-f22f1092707a"]},
"41b70c77-24a6-4a5e-b7c3-75b0dd080210"
{:id "41b70c77-24a6-4a5e-b7c3-75b0dd080210",
:kind "reference",
:link
[:output
"22f34710-72c9-46d3-bc78-b80130eec66c"
"graalvm-ce-java11-linux-amd64-21.0.0.2.tar.gz"]},
"4641de4c-67e7-4689-90f8-f22f1092707a"
{:environment
[:environment
{:article/nextjournal.id
#uuid "5b45e08b-5b96-413e-84ed-f03b5b65bd66",
:change/nextjournal.id
#uuid "5df5e18c-0be4-4d8d-b099-6ce55ca12cf4",
:node/id "0ac0b628-8b41-44d3-9023-3a688335af14"}],
:environment? true,
:id "4641de4c-67e7-4689-90f8-f22f1092707a",
:kind "runtime",
:language "bash",
:name "GraalVM",
:type :nextjournal,
:docker/environment-image
"docker.nextjournal.com/environment@sha256:e918e075951edd3d1ec8356d9de357263ef6e002fd9258fbc14d3cab039c0b57",
:runtime/environment-variables
[{:name "GRAAL_VERSION", :value "21.0.0.2"}
{:name "PATH",
:value
"/usr/local/graalvm/bin:/opt/conda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}
{:name "GRAAL_DIR", :value "/usr/local/graalvm"}
{:name "JAVA_VERSION", :value "11"}]},
"57e139fb-1a5e-43c3-b551-c1546ecb95b5"
{:id "57e139fb-1a5e-43c3-b551-c1546ecb95b5",
:kind "reference",
:ref-id "4641de4c-67e7-4689-90f8-f22f1092707a"},
"b08d71a1-411b-4850-b675-89479cd22b28"
{:compute-ref #uuid "5802d090-7673-484f-9fd9-8fc5b6f6976a",
:exec-duration 3394,
:id "b08d71a1-411b-4850-b675-89479cd22b28",
:kind "code",
:output-log-lines {:stdout 5},
:runtime [:runtime "4641de4c-67e7-4689-90f8-f22f1092707a"]},
"ddb404a8-852e-4539-b9fc-4910c9fc82c3"
{:compute-ref #uuid "9d528f13-2769-4cb8-b41d-7c1f8424acae",
:exec-duration 1281,
:id "ddb404a8-852e-4539-b9fc-4910c9fc82c3",
:kind "code",
:output-log-lines {:stdout 4},
:runtime [:runtime "4641de4c-67e7-4689-90f8-f22f1092707a"]}},
:nextjournal/id #uuid "02977b4a-ce26-4025-9a73-cbbae2521a70",
:article/change
{:nextjournal/id #uuid "60818240-46a9-4564-a93a-7bdb76676cf9"}}}
```