Skip to content

Commit caed579

Browse files
author
rieckpil
committed
update GraalVM blog post
1 parent 2e003eb commit caed579

File tree

6 files changed

+71
-77
lines changed

6 files changed

+71
-77
lines changed

graalvm-intro/.java-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11.0

graalvm-intro/.vscode/launch.json

-11
This file was deleted.

graalvm-intro/Dockerfile

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
FROM oracle/graalvm-ce:1.0.0-rc13
2-
3-
COPY src/main/java/*.java /tmp/
4-
COPY prettyMe.json /tmp/
5-
6-
# compile the Java source code to byte code
7-
RUN javac /tmp/HelloWorld.java
8-
RUN javac /tmp/PrettyPrintJSON.java
9-
10-
# create native images
11-
WORKDIR /tmp
12-
RUN native-image HelloWorld
13-
RUN native-image --language:js PrettyPrintJSON
14-
15-
RUN ./helloworld
16-
RUN ./prettyprintjson < /tmp/prettyMe.json
1+
FROM oracle/graalvm-ce:20.1.0
2+
3+
RUN gu install native-image
4+
5+
COPY src/main/java/*.java /tmp/
6+
COPY prettyMe.json /tmp/
7+
8+
# compile the Java source code to byte code
9+
RUN javac /tmp/HelloWorld.java
10+
RUN javac /tmp/PrettyPrintJSON.java
11+
12+
# create native images
13+
WORKDIR /tmp
14+
RUN native-image HelloWorld
15+
RUN native-image --language:js PrettyPrintJSON
16+
17+
RUN ./helloworld
18+
RUN ./prettyprintjson < /tmp/prettyMe.json

graalvm-intro/README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Codebase for the blog post [#WHATIS? GraalVM](https://rieckpil.de/whatis-graalvm/)
2-
3-
Steps to run this project:
4-
5-
1. Clone this Git repository
6-
2. Navigate to the folder `graalvm-intro`
7-
3. Start your docker engine
8-
4. Build the image with `docker build -t graalvmintro .` and see the native image creation and execution during build
9-
5. Optional update `src/main/java` for a new Java class of your choice and add it to the `Dockerfile`
1+
# Codebase for the blog post [GraalVM – an introduction to the next level JVM](https://rieckpil.de/whatis-graalvm/)
2+
3+
Steps to run this project:
4+
5+
1. Clone this Git repository
6+
2. Navigate to the folder `graalvm-intro`
7+
3. Start your docker engine
8+
4. Build the image with `docker build -t graalvmintro .` and see the native image creation and execution during build
9+
5. Optional update `src/main/java` for a new Java class of your choice and add it to the `Dockerfile`

graalvm-intro/pom.xml

+32-31
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4-
<modelVersion>4.0.0</modelVersion>
5-
<groupId>de.rieckpil.blog</groupId>
6-
<artifactId>graalvm-intro</artifactId>
7-
<version>0.0.1-SNAPSHOT</version>
8-
<name>Introduction into GraalVM</name>
9-
<description>Simple quickstart for GraalVM</description>
10-
11-
<properties>
12-
<maven.compiler.source>1.8</maven.compiler.source>
13-
<maven.compiler.target>1.8</maven.compiler.target>
14-
<failOnMissingWebXml>false</failOnMissingWebXml>
15-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
17-
<graalvm.version>1.0.0-rc13</graalvm.version>
18-
</properties>
19-
20-
<dependencies>
21-
<dependency>
22-
<groupId>org.graalvm.sdk</groupId>
23-
<artifactId>graal-sdk</artifactId>
24-
<version>${graalvm.version}</version>
25-
</dependency>
26-
</dependencies>
27-
28-
<build>
29-
<finalName>graalvm-intro</finalName>
30-
</build>
31-
</project>
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>de.rieckpil.blog</groupId>
7+
<artifactId>graalvm-intro</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<name>Introduction into GraalVM</name>
10+
<description>Simple quickstart for GraalVM</description>
11+
12+
<properties>
13+
<maven.compiler.source>11</maven.compiler.source>
14+
<maven.compiler.target>11</maven.compiler.target>
15+
<failOnMissingWebXml>false</failOnMissingWebXml>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
18+
<graalvm.version>20.1.0</graalvm.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.graalvm.sdk</groupId>
24+
<artifactId>graal-sdk</artifactId>
25+
<version>${graalvm.version}</version>
26+
</dependency>
27+
</dependencies>
28+
29+
<build>
30+
<finalName>graalvm-intro</finalName>
31+
</build>
32+
</project>

graalvm-intro/src/main/java/PrettyPrintJSON.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import org.graalvm.polyglot.*;
44

55
public class PrettyPrintJSON {
6-
public static void main(String[] args) throws java.io.IOException {
7-
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
8-
String input = reader.lines().collect(Collectors.joining(System.lineSeparator()));
9-
try (Context context = Context.create("js")) {
10-
Value parse = context.eval("js", "JSON.parse");
11-
Value stringify = context.eval("js", "JSON.stringify");
12-
Value result = stringify.execute(parse.execute(input));
13-
System.out.println(result.asString());
14-
}
15-
}
6+
7+
public static void main(String[] args) {
8+
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
9+
String input = reader.lines().collect(Collectors.joining(System.lineSeparator()));
10+
try (Context context = Context.create("js")) {
11+
Value parse = context.eval("js", "JSON.parse");
12+
Value stringify = context.eval("js", "JSON.stringify");
13+
Value result = stringify.execute(parse.execute(input));
14+
System.out.println(result.asString());
15+
}
16+
}
1617
}

0 commit comments

Comments
 (0)