# GraalVM

## How to install

```bash
> sdk list java; 
> sdk install java 20.2.0.r11-grl;
> sdk use java 20.2.0.r11-grl
```

## [Simple example of mixing JS and Java](https://medium.com/graalvm/using-testcontainers-from-a-node-js-application-3aa2273bf3bb)

```bash
> git clone git@github.com:kiview/testcontainers-prod-src-example.git
> cd testcontainers-prod-src-example
> ./gradlew shadowJar
> ls build/libs/testcontainers-prod-src-example-1.0-SNAPSHOT-all.jar
```

Then create a `index.js` file for node application:

```javascript
const readline = require('readline');
var GenericContainer = Java.type('org.testcontainers.containers.GenericContainer');
var container = new GenericContainer("nginx");
container.setExposedPorts([80]);
container.start();
console.log(container.getContainerIpAddress() + ':' + container.getMappedPort(80));
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
rl.question('Type something to quit? ', (answer) => {
  console.log(`Thank you! Bye!`);
  rl.close();
});
```

Assuming the folder structure is following:

* testcontainers-prod-src-example
  * build/libs/testcontainers-prod-src-example-1.0-SNAPSHOT-all.jar
* graalvm\_example
  * index.js

How to start node with java lib as a dependency:

```bash
> $JAVA_HOME/bin/node --polyglot --jvm \
--vm.cp=../testcontainers-prod-src-example/build/libs/testcontainers-prod-src-example-1.0-SNAPSHOT-all.jar \
index.js
```

in this case `echo $JAVA_HOME` returns graalvm java.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://amartyushov.gitbook.io/tech/platforms/graalvm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
