![]() |
This repository gathers GraalVM examples coming from various websites and books. It also includes several build scripts (batch files) for experimenting with GraalVM on a Windows machine. |
Ada, Akka, C++, COBOL, Dart, Deno, Docker, Erlang, Flix, Go, Haskell, Kafka, Kotlin, LLVM, Modula-2, Node.js, Rust, Scala 3, Spark, Spring, Standard ML, TruffleSqueak, WiX Toolset and Zig are other topics we are continuously monitoring.
☛ Read the document "Why GraalVM?" from the GraalVM documentation to know more about the GraalVM benefits.
This project relies on the following external software for the Microsoft Windows platform:
- Git 2.47 (release notes)
- GraalVM for JDK 17 LTS 1 (release notes)
- Microsoft Visual Studio 10 (release notes)
- Microsoft Windows SDK 7.1 (brief history)
- Python 3.11 (release notes)
Optionally one may also install the following software:
- Checkstyle 10.21 (release notes)
- CMake 3.31 (release notes)
- ConEmu 2023 (release notes)
- GraalVM for JDK 21 LTS (release notes)
- UPX 4.2 2 (changelog)
- Visual Studio Code 1.96 (release notes)
☛ Installation policy
When possible we install software from a Zip archive rather than via a Windows installer. In our case we definedC:\opt\as the installation directory for optional software tools (in reference to the/opt/directory on Unix).
For instance our development environment looks as follows (January 2025) 3:
C:\opt\ConEmu\ ( 26 MB) C:\opt\Git\ (388 MB) C:\opt\jdk-graalvm-ce-17.0.9_9.1\ (592 MB) C:\opt\jdk-graalvm-ce-21.0.1_12.1\ (585 MB) C:\opt\Python-3.11.1\ ( 82 MB) C:\opt\upx\ ( <1 MB) C:\opt\VSCode\ (370 MB) C:\Program Files\Microsoft SDKs\Windows\v7.1\ (333 MB) C:\Program Files (x86)\Microsoft Visual Studio 10.0\ (555 MB) %USERPROFILE%\.checkstyle\ ( 16 MB)
🔎 Git for Windows provides a BASH emulation used to run
git.exefrom the command line (as well as over 250 Unix commands likeawk,diff,file,grep,more,mv,rmdir,sedandwc).
This repository is organized as follows:
bin\graal\build.bat docs\ examples\{README.md, ClassInitialization, ..} graal\ (Git submodule) labsjdk-ce-17.0.9-jvmci-23.0-b22\ (385 MB) labsjdk-ce-21.0.1-jvmci-23.1-b22\ (420 MB) mx\ (Git submodule) README.md RESOURCES.md setenv.bat
where
- file
bin\graal\build.batis the batch file for building GraalVM on a Windows machine. - directory
docs\contains GraalVM related papers/articles. - directory
examples\contains GraalVM code examples (seeexamples\README.md). - directory
graal\contains a copy of the oracle/graal repository as a Github submodule. - file
README.mdis the Markdown document for this page. - file
RESOURCES.mdis the Markdown document presenting external resources. - file
setenv.batis the batch file for setting up our environment.
We also define a virtual drive – e.g. drive G: – in our working environment in order to reduce/hide the real path of our project directory (see article "Windows command prompt limitation" from Microsoft Support).
🔎 We use the Windows external command
substto create virtual drives; for instance:> subst G: %USERPROFILE%\workspace\graalvm-examples
In the next section we give a brief description of the batch files present in this project.
Batch commands ▴
We distinguish different sets of batch commands:
-
setenv.bat– This batch command makes external tools such asclang.exedorgit.exedirectly available from the command prompt (see section Project dependencies).> setenv help Usage: setenv { <option> | <subcommand> } Options: -debug print commands executed by this script -verbose print progress messages Subcommands: help print this help message
-
bin\graal\build.bat– This batch command generates the GraalVM software distribution.> build help Usage: build { <option> | <subcommand> } Options: -debug print commands executed by this script -timer print total execution time -verbose print progress messages Subcommands: clean delete generated files dist[:<n>] generate distribution with environment n=1-9 (default=2) (see environment definitions in file build.ini) help print this help message update fetch/merge local directories graal/mx
🔎 Parameter
nin subcommanddist[:<n>]refers to environmentenv<n>defined in configuration filebuild.ini.
Usage examples ▴
We execute command setenv.bat once to setup our development environment; it makes external tools such as javac.exe, cl.exe and git.exe directly available from the command prompt:
> setenv Tool versions: javac 11.0.22, python 3.11.1, pylint 2.15.8, mx 6.14.12 cl 19.29.30137, msbuild 16.11.2.50704, link 14.29.30137.0, nmake 14.29.30137.0, git 2.47.1, diff 3.10, bash 5.2.37(1) > where cl java link C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\cl.exe C:\opt\graalvm-ce-java11-22.3.2\bin\java.exe C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\link.exe
Command setenv.bat -verbose also displays the tool paths:
> setenv -verbose Tool versions: javac 11.0.22, python 3.11.1, pylint 2.15.8, mx 6.14.12 cl 19.29.30137, msbuild 16.11.2.50704, link 14.29.30137.0, nmake 14.29.30137.0, git 2.47.1, diff 3.10, bash 5.2.37(1) Tool paths: C:\opt\graalvm-ce-java11-22.3.2\bin\javac.exe C:\opt\Python-3.11.1\python.exe C:\opt\Python-3.11.1\Scripts\pylint.exe G:\graalvm\mx\mx.cmd C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\cl.exe C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\link.exe C:\opt\Git\usr\bin\link.exe C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\nmake.exe C:\opt\Git\bin\git.exe Environment variables: "GIT_HOME=C:\opt\Git" "GRAALVM_HOME=C:\opt\graalvm-ce-java11-22.3.2 "GRAALVM11_HOME=C:\opt\graalvm-ce-java11-22.3.2" "GRAALVM17_HOME=C:\opt\graalvm-ce-java17-22.3.2" "JAVA_HOME=C:\opt\graalvm-ce-java11-22.3.2" "LLVM_HOME=C:\opt\LLVM-15.0.6" "MAKE_HOME=C:\opt\make-3.81" "MAVEN_HOME=C:\opt\apache-maven" "MSVC_BIN_DIR=X:\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64" "MSVC_HOME=X:\VC\Tools\MSVC\14.29.30133" "MSVS_HOME=X:" "PYTHON_HOME=C:\opt\Python-3.11.1" "WABT_HOME=C:\opt\wabt-1.0.23" Path associations: G:\: => %USERPROFILE%\workspace-perso\graalvm-examples
Directory graal\ is a Github submodule with a copy of the oracle/graal repository; it is setup as follows:
> cp bin\graal\build.* graal > cd graal
Usage examples of command build.bat are presented in document BUILD.md.
See document examples\README.md.
See document RESOURCES.md for GraalVM related resources.
Footnotes ▴
[1] Two GraalVM editions ↩
- GraalVM is available as Community Edition (CE) and Enterprise Edition (EE): GraalVM CE is based on the OpenJDK 8 and GraalVM EE is developed on top of the Java SE 1.8.0_302.
[2] UPX ↩
-
UPX (Ultimate Packer for eXecutables) is a free, portable, extendable, high-performance executable packer for several executable formats. It is particularly useful to reduce the size of executables produced by
native-image.
[3] Downloads ↩
- In our case we downloaded the following installation files (see section 1):
-
ConEmuPack.230724.7z ( 5 MB) graalvm-community-java21-windows-amd64-dev.zip (*) (298 MB) graalvm-community-jdk-17.0.8_windows-x64_bin.zip (*) (297 MB) GRMSDKX_EN_DVD.iso (570 MB) labsjdk-ce-17.0.9+9-jvmci-23.0-b22-windows-amd64.tar.gz (190 MB) labsjdk-ce-21.0.1+12-jvmci-23.1-b22-windows-amd64.tar.gz (181 MB) PortableGit-2.46.0-64-bit.7z.exe ( 41 MB) python-3.11.1.amd64.msi ( 19 MB) upx-4.2.2-win64.zip ( <1 MB) VC-Compiler-KB2519277.exe (121 MB) VSCode-win32-x64-1.96.4.zip (131 MB)
(*) The toolnative-imagewas initially installed separately with GraalVM distributions and is now included in GraalVM for JDK distributions (see article "New GraalVM Release and new Free Licence!").
[4] Improvements in GraalVM 20 ↩
- Versions 20.x of GraalVM bring major improvements to Windows users:
-
- Command
gu.cmdis finally part of the Windows distribution !> where /r c:\opt\jdk-graalvm-ce-17.0.9_9.1 gu.* c:\opt\jdk-graalvm-ce-17.0.9_9.1\bin\gu.cmd c:\opt\jdk-graalvm-ce-17.0.9_9.1\lib\installer\bin\gu.cmd
native-imageandrebuild-imagesare now available as an installable component.> echo %JAVA_HOME% C:\opt\graalvm-ce-java11-22.3.2 > %JAVA_HOME%\bin\gu.cmd install --file native-image-installable-svm-java11-windows-amd64-22.3.2.jar --verbose Processing Component archive: native-image-installable-svm-java11-windows-amd64-22.3.2.jar Preparing to install native-image-installable-svm-java11-windows-amd64-22.3.2.jar, contains org.graalvm.native-image, version 22.3.2 (org.graalvm.native-image) Checking requirements of component Native Image (native-image), version 22.3.2 Requires Graal Version = 22.3.2, GraalVM provides: 22.3.2 Requires Java Version = 11, GraalVM provides: 11 Requires Architecture = amd64, GraalVM provides: amd64 Requires Operating System = windows, GraalVM provides: windows Installing new component: Native Image (org.graalvm.native-image, version 22.3.2) Extracting: LICENSE_NATIVEIMAGE.txt Extracting: bin/native-image.cmd Extracting: bin/rebuild-images.cmd [..] > %JAVA_HOME%\bin\gu.cmd list ComponentId Version Component name Stability Origin --------------------------------------------------------------------------- graalvm 22.3.2 GraalVM Core Supported espresso 22.3.2 Java on Truffle Experimental native-image 22.3.2 Native Image Early adopter > c:\opt\graalvm-ce-java11-22.3.2\bin\native-image.cmd --version GraalVM 22.3.2 Java 11 CE (Java Version 11.0.19+10-jvmci-22.3-b08)
- Command
polyglot.cmdis finally part of the Windows distribution (and is native).> where /r c:\opt\graalvm-ce-java11-22.3.2\ polyglot.cmd c:\opt\graalvm-ce-java11-22.3.2\bin\polyglot.cmd c:\opt\graalvm-ce-java11-22.3.2\lib\polyglot\bin\polyglot.cmd > c:\opt\graalvm-ce-java11-22.3.2\bin\polyglot.cmd --version GraalVM CE polyglot launcher 22.3.2
- Command
[5] JDK 11 Support ↩
- Oracle has retired JDK 11 support starting with GraalVM 23.0 (to be released in June 2023).
