Skip to content

Commit 87f88bb

Browse files
[GR-61796] Improve espresso documentation.
PullRequest: graal/19962
2 parents 977e596 + e71da05 commit 87f88bb

File tree

3 files changed

+28
-37
lines changed

3 files changed

+28
-37
lines changed

docs/reference-manual/java-on-truffle/README.md

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ Espresso passes the Java Compatibility Kit (JCK or TCK for Java SE).
3333
Espresso is available as a standalone distribution that provides a Java 21 environment.
3434
You can download a standalone based on Oracle GraalVM or GraalVM Community Edition.
3535

36-
1. Download the Espresso 24.0 standalone for your operating system:
36+
1. Download the Espresso 24.1 standalone for your operating system:
3737

38-
* [Linux x64](https://gds.oracle.com/download/espresso/archive/espresso-java21-24.0.1-linux-amd64.tar.gz)
39-
* [Linux AArch64](https://gds.oracle.com/download/espresso/archive/espresso-java21-24.0.1-linux-aarch64.tar.gz)
40-
* [macOS x64](https://gds.oracle.com/download/espresso/archive/espresso-java21-24.0.1-macos-amd64.tar.gz)
41-
* [macOS AArch64](https://gds.oracle.com/download/espresso/archive/espresso-java21-24.0.1-macos-aarch64.tar.gz)
42-
* [Windows x64](https://gds.oracle.com/download/espresso/archive/espresso-java21-24.0.1-windows-amd64.zip)
38+
* [Linux x64](https://gds.oracle.com/download/espresso/archive/espresso-java21-24.1.2-linux-amd64.tar.gz)
39+
* [Linux AArch64](https://gds.oracle.com/download/espresso/archive/espresso-java21-24.1.2-linux-aarch64.tar.gz)
40+
* [macOS x64](https://gds.oracle.com/download/espresso/archive/espresso-java21-24.1.2-macos-amd64.tar.gz)
41+
* [macOS AArch64](https://gds.oracle.com/download/espresso/archive/espresso-java21-24.1.2-macos-aarch64.tar.gz)
42+
* [Windows x64](https://gds.oracle.com/download/espresso/archive/espresso-java21-24.1.2-windows-amd64.zip)
4343

4444
2. Unzip the archive:
4545
```shell
@@ -49,41 +49,42 @@ You can download a standalone based on Oracle GraalVM or GraalVM Community Editi
4949
3. A standalone comes with a JVM in addition to its native launcher. Check the version to see the runtime is active:
5050
```shell
5151
# Path to Espresso installation
52-
./path/to/bin/java -truffle -version
52+
./path/to/bin/java -version
5353
```
5454

5555
## Run a Java Application on Espresso
5656

57-
You can run a Java application on Espresso, by passing the `-truffle` option to the standard `java` launcher.
58-
This is similar to how you used to switch between the `-client` and `-server` JVMs.
57+
The `java` launcher included in the Espresso standalone works like the standard `java` launcher:
5958

6059
To execute a class file:
6160
```shell
62-
java -truffle [options] class
61+
java [options] class
6362
```
6463
To execute a JAR file:
6564
```shell
66-
java -truffle [options] -jar jarfile
65+
java [options] -jar jarfile
6766
```
6867

6968
You can also run a Java application from the main class in a module, or run a single source-file program:
7069
```shell
71-
java -truffle [options] -m module[/<mainclass>]
72-
java -truffle [options] sourcefile
70+
java [options] -m module[/<mainclass>]
71+
java [options] sourcefile
7372
```
7473

75-
By default, Espresso runs within GraalVM by reusing all GraalVM's JAR files and native libraries, but it is possible to "cross-version" and specify a different Java installation directory (`java.home`).
76-
It will automatically switch versions regardless of the host JVM.
74+
By default, Espresso runs with the standard library included in the standalone, but it is possible to specify a different Java installation directory (`java.home`).
75+
It will automatically switch versions as long as the new Java home is a supported version (8, 11, 17, or 21).
7776
```shell
78-
java -truffle --java.JavaHome=/path/to/java/home -version
77+
java --java.JavaHome=/path/to/java/home -version
7978
```
8079

80+
> Note: If you use `-server` option of the `java` launcher, espresso will not be used and HotSpot will be started instead.
81+
> You can also use `-truffle` to explicitly require the use of espreso (the default).
82+
8183
## Performance Considerations
8284

8385
The startup time will not match the speed offered by the regular GraalVM just-in-time (JIT) execution yet, but having created a fully working Espresso runtime, the development team is now focusing on performance.
84-
You can still influence the performance by passing the following options to `java -truffle`:
85-
* `--engine.MultiTier=true` to enable multi-tier compilation;
86-
* `--engine.Inlining=false` in combination with `--java.InlineFieldAccessors=true` to make the compilation faster, in exchange for slower performance.
86+
You can still influence the performance by passing the following option to `java`:
87+
* `--engine.Mode=latency` to enable Truffle's latency mode to make JIT compilation faster, in exchange for slower peak performance.
8788
8889
The `--vm.XX:` syntax ensures the option is passed to the underlying [Native Image VM](../native-image/BuildOptions.md).
8990
When using the `-XX:` syntax, the VM first checks if there is such an option in the Espresso runtime.
@@ -97,7 +98,7 @@ This might be important for options such as `MaxDirectMemorySize` which can be s
9798
To ensure you have successfully installed Espresso, verify its version:
9899
```shell
99100
# Path to Espresso installation
100-
./path/to/bin/java -truffle -version
101+
./path/to/bin/java -version
101102
```
102103
103104
Taking this `HelloWorld.java` example, compile it and run from the command line:
@@ -111,7 +112,7 @@ public class HelloWorld {
111112
112113
```shell
113114
$JAVA_HOME/bin/javac HelloWorld.java
114-
$JAVA_HOME/bin/java -truffle HelloWorld
115+
$JAVA_HOME/bin/java HelloWorld
115116
```
116117
117118
Taking some real-world applications, try running [Spring PetClinic](https://github.com/spring-projects/spring-petclinic) - a sample web application that demonstrates the use of Spring Boot with Spring MVC and Spring Data JPA.
@@ -127,42 +128,32 @@ Taking some real-world applications, try running [Spring PetClinic](https://gith
127128
./mvnw package
128129
```
129130
130-
3. Then run it from the command line by selecting the `-truffle` runtime:
131-
```java
132-
java -truffle -jar target/spring-petclinic-<version>-SNAPSHOT.jar
131+
3. Then run it from the command line:
132+
```shell
133+
java -jar target/spring-petclinic-<version>-SNAPSHOT.jar
133134
```
134135
135136
4. When the application starts, access it on [localhost:8000](http://localhost:8080/).
136137
137138
#### From IDE
138139
139-
To run a Java project on Espresso from an IDE requires setting GraalVM as a project's default JDK and enabling the Espresso execution mode.
140+
To run a Java project on Espresso from an IDE, you need to set the Espresso standalone as the project's default JDK.
140141
For example, to run the Spring PetClinic project using Intellij IDEA, you need to:
141142

142-
1. Navigate to **File**, then to **Project Structure**. Click **Project**, and then click **Project SDK**. Expand the drop down, press Add **JDK** and open the directory where you installed GraalVM. For macOS users, JDK home path will be `/Library/Java/JavaVirtualMachines/{graalvm}/Contents/Home`. Give it a name, and press Apply.
143+
1. Navigate to **File**, then to **Project Structure**. Click **Project**, and then click **Project SDK**. Expand the drop down, press Add **JDK**, and open the directory where you installed the Espresso standalone. For macOS users, JDK home path will be `/Library/Java/JavaVirtualMachines/{espresso-standalone}/Contents/Home`. Give it a name, and press Apply.
143144

144145
![Intellij IDEA: Add Project Name](images/add-project-default-sdk.png)
145146

146147
2. Generate sources and update folders for the project. In the Maven sidebar, click on the directory with the spinner icon:
147148

148149
![Intellij IDEA: Generate Project Sources](images/generate-project-sources.png)
149150

150-
3. Enable Espresso. From the main menu select **Run**, then **Run…**. Click **Edit Configurations** and choose **Environment**. Put the `-truffle -XX:+IgnoreUnrecognizedVMOptions` command in **VM options** and press Apply.
151-
152-
![Intellij IDEA: Enable Environment Configuration](images/pass-vmoption.png)
153-
154-
It is necessary to specify `-XX:+IgnoreUnrecognizedVMOptions` because Intellij automatically adds a `-javaagent` argument which is not supported yet.
155-
156-
4. Press Run.
151+
3. Press Run.
157152

158153
## Debugging
159154

160155
You do not have to configure anything special to debug Java applications running Espresso from your favorite IDE debugger.
161156
For example, starting a debugger session from IntelliJ IDEA is based on the Run Configurations.
162-
To ensure you attach the debugger to your Java application in the same environment, navigate in the main menu to Run -> Debug… -> Edit Configurations, expand Environment, check the JRE value and VM options values.
163-
It should show GraalVM as project's JRE, and VM options should include `-truffle -XX:+IgnoreUnrecognizedVMOptions`, where `-truffle` enables Espresso, and `-XX:+IgnoreUnrecognizedVMOptions` is a temporary workaround since the Espresso runtime does not yet support attaching Java agents.
164-
165-
![Intellij IDEA: Debug Configuration](images/debug-configuration.png)
166157

167158
## What to Read Next
168159

Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)