Skip to content

Commit

Permalink
Switch from GraalVM EE to Oracle GraalVM
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-pikle committed Jan 17, 2024
1 parent 95076d9 commit 8d97b5e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 36 deletions.
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

0 comments on commit 8d97b5e

Please sign in to comment.