Skip to content

Latest commit

 

History

History

graalpy-jbang-qrcode

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

GraalPy JBang QRCode Demo

This demo illustrates how GraalPy can be used to embed the qrcode Python package in a script that runs on JBang.

Preparation

Install GraalVM for JDK 23 and set the value of JAVA_HOME accordingly. We recommend using SDKMAN!. (For other download options, see GraalVM Downloads.)

sdk install java 23-graal

Afterward, install jbang, for with:

sdk install jbang

Run the Application

To start the demo, run:

jbang run qrcode.java "Hello from GraalPy!"

Implementation Details

qrcode.java defines required dependencies on GraalPy, which also allows to depend on Python packages. //PIP qrcode==7.4.2 defines the dependency on the qrcode Python package. The main() method checks the arguments and then creates a new Context. It then fetches the qrcode Python module and maps it to a QRCode Java interface. Afterward, it uses the qrcode module as illustrated in this example through Java interfaces. Finally, it prints the result to System.out.