Skip to content

Commit

Permalink
Switch from GraalVM EE to Oracle GraalVM (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-pikle authored Jan 18, 2024
1 parent 95076d9 commit fa897f5
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 88 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ cd graalvm-demos
<tbody>
<tr>
<td align="left" width="30%"><a href="/spring-native-image/">spring-native-image</a><br><a href="https://github.com/graalvm/graalvm-demos/actions/workflows/spring-native-image.yml"><img alt="spring-native-image" src="https://github.com/graalvm/graalvm-demos/actions/workflows/spring-native-image.yml/badge.svg" /></a></td>
<td align="left" width="70%">Demonstrates how to compile a Spring Boot application into a native executable using the Native Build Tools Maven plugin and a Maven profile <br> <strong>Technologies: </strong>Spring Boot, Native Image, Native Build Tools Maven plugin <br><strong>Reference: </strong><a href="https://luna.oracle.com/lab/fdfd090d-e52c-4481-a8de-dccecdca7d68/steps">GraalVM Native Image, Spring and Containerisation</a>, <a href="https://docs.oracle.com/en/graalvm/jdk/21/docs/getting-started/oci/cloud-shell/">GraalVM Enterprise in OCI Cloud Shell</a></td>
<td align="left" width="70%">Demonstrates how to compile a Spring Boot application into a native executable using the Native Build Tools Maven plugin and a Maven profile <br> <strong>Technologies: </strong>Spring Boot, Native Image, Native Build Tools Maven plugin <br><strong>Reference: </strong><a href="https://luna.oracle.com/lab/fdfd090d-e52c-4481-a8de-dccecdca7d68/steps">GraalVM Native Image, Spring and Containerisation</a>, <a href="https://docs.oracle.com/en/graalvm/jdk/21/docs/getting-started/oci/cloud-shell/">Oracle GraalVM in OCI Cloud Shell</a></td>
</tr>
<tr>
<td align="left" width="30%"><a href="/spring-r/">spring-r</a><br><a href="https://github.com/graalvm/graalvm-demos/actions/workflows/spring-r.yml"><img alt="spring-r" src="https://github.com/graalvm/graalvm-demos/actions/workflows/spring-r.yml/badge.svg" /></a></td>
Expand Down
20 changes: 11 additions & 9 deletions _common/README-check-version-env-vars.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [OPTIONAL] Confirm software version and environment variables
## [OPTIONAL] Confirm Software Version and Environment Variables

1. Confirm GraalVM is the current JDK:

Expand All @@ -9,9 +9,9 @@
The output should be similar to (versions may vary):

```shell
* graalvmeejdk-17 /usr/lib64/graalvm/graalvm22-ee-java17
oraclejdk-1.8 /usr/java/jdk1.8.0_351-amd64
* graalvmjdk-17 /usr/lib64/graalvm/graalvm-java17
oraclejdk-11 /usr/java/jdk-11.0.17
oraclejdk-1.8 /usr/lib/jvm/jdk-1.8-oracle-x64
```

2. Confirm the environment variable `JAVA_HOME` is set correctly:
Expand All @@ -23,7 +23,7 @@
The output should be similar to:

```shell
/usr/lib64/graalvm/graalvm22-ee-java17
/usr/lib64/graalvm/graalvm-java17
```

3. Confirm the environment variable `PATH` is set correctly:
Expand All @@ -35,7 +35,7 @@
The output should be similar to:

```shell
/usr/lib64/graalvm/graalvm22-ee-java17/bin/:...
/usr/lib64/graalvm/graalvm-java17/bin/:...
```

4. Confirm the `java` version:
Expand All @@ -48,8 +48,8 @@

```shell
java version "17.0.9" 2023-10-17 LTS
Java(TM) SE Runtime Environment GraalVM EE 22.3.4 (build 17.0.9+11-LTS-jvmci-22.3-b28)
Java HotSpot(TM) 64-Bit Server VM GraalVM EE 22.3.4 (build 17.0.9+11-LTS-jvmci-22.3-b28, mixed mode, sharing)
Java(TM) SE Runtime Environment Oracle GraalVM 17.0.9+11.1 (build 17.0.9+11-LTS-jvmci-23.0-b21)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.9+11.1 (build 17.0.9+11-LTS-jvmci-23.0-b21, mixed mode, sharing)
```

5. Confirm the `native-image` version:
Expand All @@ -61,7 +61,9 @@
The output should be similar to (versions may vary):

```shell
GraalVM 22.3.4 Java 17 EE (Java Version 17.0.9+11-LTS-jvmci-22.3-b28)
native-image 17.0.9 2023-10-17
GraalVM Runtime Environment Oracle GraalVM 17.0.9+11.1 (build 17.0.9+11-LTS-jvmci-23.0-b21)
Substrate VM Oracle GraalVM 17.0.9+11.1 (build 17.0.9+11-LTS, serial gc, compressed references)
```

6. Confirm the `Java` used for Maven builds:
Expand All @@ -74,7 +76,7 @@

```shell
...
Java version: 17.0.9, vendor: Oracle Corporation, runtime: /usr/lib64/graalvm/graalvm22-ee-java17
Java version: 17.0.9, vendor: Oracle Corporation, runtime: /usr/lib64/graalvm/graalvm-java17
...
```

Expand Down
45 changes: 24 additions & 21 deletions java-hello-world-maven/README-Cloud-Shell.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Java Hello World with GraalVM Enterprise in OCI Cloud Shell
# Java Hello World with Oracle GraalVM in OCI Cloud Shell

This example shows how you can get started quickly with GraalVM Enterprise Edition in Oracle Cloud Infrastructre (OCI) Cloud Shell. This example uses a simple hello world Java application built with GraalVM Enterprise Native Image and JDK (Java Development Kit).
This example shows how you can get started quickly with Oracle GraalVM in Oracle Cloud Infrastructure (OCI) Cloud Shell. This example uses a simple hello world Java application built with Oracle GraalVM Native Image and JDK (Java Development Kit).

## What is GraalVM?

[GraalVM](https://www.oracle.com/in/java/graalvm/) is a high-performance JDK distribution that accelerates Java workloads. GraalVM Native Image ahead-of-time compilation builds your Java application into a native executable that is small, starts fast, and uses less memory and CPU. Leading Java microservices frameworks such as Spring Boot, Micronaut, Quarkus and Helidon support GraalVM Native Image.

GraalVM Enterprise Edition is available for use on Oracle Cloud Infrastructure (OCI) at no additional cost.
Oracle GraalVM is available for use on Oracle Cloud Infrastructure (OCI) at no additional cost.

## What is Cloud Shell?

[Cloud Shell](https://www.oracle.com/devops/cloud-shell/) is a free-to-use browser-based terminal accessible from the Oracle Cloud Console. It provides access to a Linux shell with preinstalled developer tools and a preauthenticated OCI CLI. You can use the shell to interact with OCI resources, follow labs and tutorials, and quickly run utility commands.

GraalVM Enterprise JDK 17 and Native Image are preinstalled in Cloud Shell, so you don’t have to install and configure a development machine to get started.
Oracle GraalVM for JDK 17 (with Native Image) is preinstalled in Cloud Shell, so you don’t have to install and configure a development machine to get started.

## Step 1: Launch Cloud Shell
## Step 1: Launch Cloud Shell

1. [Login to OCI Console and launch Cloud Shell](https://cloud.oracle.com/?bdcstate=maximized&cloudshell=true).

## Step 2: Select GraalVM as the current JDK
## Step 2: Select GraalVM as the current JDK

1. List the installed JDKs:

Expand All @@ -29,21 +29,21 @@ GraalVM Enterprise JDK 17 and Native Image are preinstalled in Cloud Shell, so y
The output should be similar to:

```shell
graalvmeejdk-17 /usr/lib64/graalvm/graalvm22-ee-java17
* oraclejdk-1.8 /usr/java/jdk1.8.0_351-amd64
oraclejdk-11 /usr/java/jdk-11.0.17
graalvmjdk-17 /usr/lib64/graalvm/graalvm-java17
* oraclejdk-11 /usr/java/jdk-11.0.17
oraclejdk-1.8 /usr/lib/jvm/jdk-1.8-oracle-x64
```

2. Select GraalVM as the current JDK:

```shell
csruntimectl java set graalvmeejdk-17
csruntimectl java set graalvmjdk-17
```

The output should be similar to:

```shell
The current managed java version is set to graalvmeejdk-17.
The current managed java version is set to graalvmjdk-17.
```

## Step 3: [OPTIONAL] Confirm software version and environment variables
Expand Down Expand Up @@ -85,7 +85,8 @@ This step is optional - [Check software version and environment variables](../_c
```

The output should be similar to:
```

```text
Hello World!
```

Expand All @@ -99,8 +100,8 @@ You will notice the `Quick Build` mode reduces the time required to generate a n

1. To enable `Quick Build`, open [pom.xml](./pom.xml) in a text editor such as Nano and uncomment the line shown:

```
<buildArg>-Ob</buildArg>
```xml
<quickBuild>true</quickBuild>
```

2. Use the Native Image maven plugin to create a native executable:
Expand All @@ -116,17 +117,18 @@ You will notice the `Quick Build` mode reduces the time required to generate a n
```

The output should be similar to:
```

```text
Hello World!
```


**Option 2: Quick Build disabled**

1. To disable `Quick Build`, open [pom.xml](pom.xml) in a text editor such as Nano and comment the line shown:
**Option 2: Quick Build disabled**

```
<!-- <buildArg>-Ob</buildArg> -->
1. To disable `Quick Build`, open [pom.xml](pom.xml) in a text editor such as Nano and comment the line shown:

```xml
<!-- <quickBuild>true</quickBuild> -->
```

2. Use the Native Image maven plugin to create a native executable:
Expand All @@ -142,6 +144,7 @@ You will notice the `Quick Build` mode reduces the time required to generate a n
```

The output should be similar to:
```

```text
Hello World!
```
8 changes: 4 additions & 4 deletions java-hello-world-maven/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Java Hello World with GraalVM Enterprise
# Java Hello World with Oracle GraalVM

In this example, you will build and run a "Hello World" Java application with
In this example, you will build and run a "Hello World" Java application with:

- [GraalVM Enterprise in OCI Code Editor](https://github.com/oracle-devrel/oci-code-editor-samples/tree/main/java-samples/graalvmee-java-hello-world)
- [GraalVM Enterprise in OCI Cloud Shell](./README-Cloud-Shell.md)
- [Oracle GraalVM in OCI Code Editor](https://github.com/oracle-devrel/oci-code-editor-samples/tree/main/java-samples/graalvmee-java-hello-world)
- [Oracle GraalVM in OCI Cloud Shell](./README-Cloud-Shell.md)
20 changes: 9 additions & 11 deletions java-hello-world-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<groupId>com.gvm.samples</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>

<name>my-app</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<url>http://www.oracle.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -48,7 +48,7 @@
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>native</id>
Expand Down Expand Up @@ -77,18 +77,16 @@
</executions>
<configuration>
<imageName>my-app</imageName>
<verbose>true</verbose>
<!-- For Quick Build (22.1+) -->
<!-- <quickBuild>true</quickBuild> -->
<buildArgs>
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
<!-- For mostly static native image (only on Linux AMD64 systems) -->
<!-- <buildArg>-H:+StaticExecutableWithDynamicLibC</buildArg> -->
<buildArg>--verbose</buildArg>
<!-- For Quick Build (22.1+) -->
<buildArg>-Ob</buildArg>
<!-- To generate the Native Image build output JSON (22.3+) -->
<buildArg>-H:BuildOutputJSONFile=build.json</buildArg>
</buildArgs>
<!-- Start: Workaround for 22.2: Disable the default Java Module Path using USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM -->
<!-- <environment>
<USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM>false</USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM>
</environment> -->
<!-- End: Workaround for 22.2: Disable the default Java Module Path using USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM -->
</configuration>
</plugin>
</plugins>
Expand Down
14 changes: 7 additions & 7 deletions micronaut-hello-rest-maven/README-Cloud-Shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Micronaut uses GraalVM Native Image to build lightweight Java applications that

[Cloud Shell](https://www.oracle.com/devops/cloud-shell/) is a free-to-use browser-based terminal accessible from the Oracle Cloud Console. It provides access to a Linux shell with preinstalled developer tools and a preauthenticated OCI CLI. You can use the shell to interact with OCI resources, follow labs and tutorials, and quickly run utility commands.

Oracle GraalVM Enterprise JDK 17 and Native Image are preinstalled in Cloud Shell, so you don’t have to install and configure a development machine to get started.
Oracle GraalVM for JDK 17 (with Native Image) is preinstalled in Cloud Shell, so you don’t have to install and configure a development machine to get started.

## Step 1: Launch Cloud Shell

Expand All @@ -35,21 +35,21 @@ Oracle GraalVM Enterprise JDK 17 and Native Image are preinstalled in Cloud Shel
The output should be similar to (versions may vary):

```shell
graalvmeejdk-17 /usr/lib64/graalvm/graalvm22-ee-java17
* oraclejdk-1.8 /usr/java/jdk1.8.0_351-amd64
oraclejdk-11 /usr/java/jdk-11.0.17
graalvmjdk-17 /usr/lib64/graalvm/graalvm-java17
* oraclejdk-11 /usr/java/jdk-11.0.17
oraclejdk-1.8 /usr/lib/jvm/jdk-1.8-oracle-x64
```

2. Select GraalVM as the current JDK:

```shell
csruntimectl java set graalvmeejdk-17
csruntimectl java set graalvmjdk-17
```

The output should be similar to:

```shell
The current managed java version is set to graalvmeejdk-17.
The current managed java version is set to graalvmjdk-17.
```

## Step 3: Set up your project, build and run as a JAR
Expand All @@ -73,7 +73,7 @@ Oracle GraalVM Enterprise JDK 17 and Native Image are preinstalled in Cloud Shel
```

2. [OPTIONAL] Confirm software version and environment variables.
2. [OPTIONAL] Confirm software version and environment variables.

[Check software version and environment variables](../_common/README-check-version-env-vars.md)

Expand Down
6 changes: 4 additions & 2 deletions micronaut-hello-rest-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<parent>
<groupId>io.micronaut.platform</groupId>
<artifactId>micronaut-parent</artifactId>
<version>4.2.1</version>
<version>4.2.3</version>
</parent>
<properties>
<packaging>jar</packaging>
<jdk.version>17</jdk.version>
<release.version>17</release.version>
<micronaut.version>4.2.1</micronaut.version>
<micronaut.version>4.2.3</micronaut.version>
<micronaut.runtime>netty</micronaut.runtime>
<micronaut.aot.enabled>false</micronaut.aot.enabled>
<micronaut.aot.packageName>com.example.aot.generated</micronaut.aot.packageName>
Expand Down Expand Up @@ -121,6 +121,8 @@
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
<!-- For mostly static native image (only on Linux AMD64 systems) -->
<!-- <buildArg>-H:+StaticExecutableWithDynamicLibC</buildArg> -->
<!-- To generate the Native Image build output JSON (22.3+) -->
<buildArg>-H:BuildOutputJSONFile=build.json</buildArg>
</buildArgs>
</configuration>
</plugin>
Expand Down
29 changes: 15 additions & 14 deletions spring-native-image/README-Cloud-Shell.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Spring Boot Microservice with GraalVM Enterprise in OCI Cloud Shell
# Spring Boot Microservice with Oracle GraalVM in OCI Cloud Shell

This part shows how you can get started quickly with GraalVM Enterprise Edition in Oracle Cloud Infrastructure (OCI) Cloud Shell using the Spring Boot 3 microservice example.
This part shows how you can get started quickly with Oracle GraalVM in Oracle Cloud Infrastructure (OCI) Cloud Shell using the Spring Boot 3 microservice example.

GraalVM Enterprise Edition is available for use on Oracle Cloud Infrastructure (OCI) at no additional cost.
Oracle GraalVM is available for use on Oracle Cloud Infrastructure (OCI) at no additional cost.

## What is Cloud Shell?

[Cloud Shell](https://www.oracle.com/devops/cloud-shell/) is a free-to-use browser-based terminal accessible from the Oracle Cloud Console. It provides access to a Linux shell with preinstalled developer tools and a pre-authenticated OCI CLI. You can use the shell to interact with OCI resources, follow labs and tutorials, and quickly run utility commands.

GraalVM Enterprise JDK 17 and Native Image are preinstalled in Cloud Shell, so you do not have to install and configure a development machine to get started.
Oracle GraalVM for JDK 17 (with Native Image) is preinstalled in Cloud Shell, so you don’t have to install and configure a development machine to get started.

## Step 1: Launch Cloud Shell
## Step 1: Launch Cloud Shell

[Login to OCI Console and launch Cloud Shell](https://cloud.oracle.com/?bdcstate=maximized&cloudshell=true).

## Step 2: Select GraalVM as the Current JDK
## Step 2: Select GraalVM as the Current JDK

1. List the installed JDKs:

Expand All @@ -25,20 +25,21 @@ GraalVM Enterprise JDK 17 and Native Image are preinstalled in Cloud Shell, so y
The output should be similar to (versions may vary):

```shell
graalvmeejdk-17 /usr/lib64/graalvm/graalvm22-ee-java17
* oraclejdk-1.8 /usr/java/jdk1.8.0_351-amd64
oraclejdk-11 /usr/java/jdk-11.0.17
graalvmjdk-17 /usr/lib64/graalvm/graalvm-java17
* oraclejdk-11 /usr/java/jdk-11.0.17
oraclejdk-1.8 /usr/lib/jvm/jdk-1.8-oracle-x64
```

2. Select GraalVM as the current JDK:

```shell
csruntimectl java set graalvmeejdk-17
csruntimectl java set graalvmjdk-17
```

The output should be similar to:

```shell
The current managed java version is set to graalvmeejdk-17.
The current managed java version is set to graalvmjdk-17.
```

## Step 3: (Optional) Confirm Software Version and Environment Variables
Expand Down Expand Up @@ -78,7 +79,7 @@ This step is optional - [Check software version and environment variables](../_c
java -jar ./target/benchmark-jibber-0.0.1-SNAPSHOT.jar &
```

4. Test the app JAR.
4. Test the app JAR.

```shell
curl http://localhost:8080/jibber
Expand Down Expand Up @@ -110,14 +111,14 @@ This step is optional - [Check software version and environment variables](../_c

## Step 5: Build and Run a Native Executable

Now build a native executable for your Spring Boot microservice using GraalVM Enterprise Native Image.
Now build a native executable for your Spring Boot microservice using Oracle GraalVM Native Image.

1. Build the app native executable

```shell
mvn -Pnative native:compile
```

This will create a binary executable `target/benchmark-jibber`.

2. Run the app native executable in the background
Expand Down
Loading

0 comments on commit fa897f5

Please sign in to comment.