You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68-23Lines changed: 68 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,17 +2,44 @@
2
2
3
3
# Pico JVM
4
4
5
-
This is a Java virtual machine for the [Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/), this project is based on the [CLDC](https://en.wikipedia.org/wiki/Connected_Limited_Device_Configuration) virtual machine and more specificly on the [phoneME](https://phonej2me.github.io) project from Sun/Oracle. The [phoneME](https://phonej2me.github.io) is a very old project that currently is not maintaned anymore. However I was able to find a github [repo](https://github.com/magicus/phoneME) that I used as a reference. This JVM is targeted to small embedded devices with limited resources so don't expected a full blown Java experience on [Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/).
5
+
This is a Java virtual machine for the [Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/), this project is based on the [CLDC](https://en.wikipedia.org/wiki/Connected_Limited_Device_Configuration) virtual machine and more specifically on the [phoneME](https://phonej2me.github.io) project from Sun/Oracle. The [phoneME](https://phonej2me.github.io) is a very old project that currently is not maintained anymore. However I was able to find a github [repo](https://github.com/magicus/phoneME) that I used as a reference. This JVM is targeted to small embedded devices with limited resources so don't expected a full blown Java experience on [Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/).
6
6
7
7
The original [phoneME](https://phonej2me.github.io) project used a Makefile based build system, I converted the build system to CMake so I can use more modern tools and integration with modern CI/CD workflows. There are currently two main targets : Linux (used mainly for debugging) and Pico.
8
8
9
9
Currently the JVM support [CLDC 1.1](https://docs.oracle.com/javame/config/cldc/ref-impl/cldc1.1/jsr139/index.html) specification which is a limited subset of the Java J2SE specification and language.
10
10
11
-
## Running a Java application
11
+
## Installation and setup
12
12
13
-
To run a Java application on the [Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) you will need to flash the Java virtual machine itself and than flash the Java application at the address `0x10100000`.
13
+
Download the release package from the [Releases](https://github.com/orenskl/pico-jvm/releases) page of this repository, extract the package. The package contains the following content :
14
+
15
+
```
16
+
├── bin
17
+
├── doc
18
+
├── lib
19
+
└── pjvm-X.Y.Z.uf2
20
+
```
21
+
22
+
The `bin` directory contains tools and scripts required to post process class and jar files to be able to run them on the [Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/).
23
+
24
+
The `doc` directory contains the javadoc for the device specific (e.g. GPIO) classes.
25
+
26
+
The `lib` directory contains the run-time class libraries (`classes.jar`)
27
+
28
+
The `pjvm-X.Y.Z.uf2` (where X.Y.Z is the version of the firmware) is the Java Virtual Machine UF2 file, this file needs to be flashed to the [Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) using [picotool](https://github.com/raspberrypi/picotool). The virtual machine already contains the run time classes so these are not required to be flashed separately.
14
29
15
-
The Java VM can be dowloaded from the [Releases](https://github.com/orenskl/pico-jvm/releases) page of this project. You can download the gzipped UF2 file, unpack it and flash it with the standard [picotool](https://github.com/raspberrypi/picotool).
30
+
The `examples` directory in this repository contains some examples you can run with an [Ant](https://ant.apache.org)`build.xml` file. To build the examples and the following Hello World application you will need to setup the environment variable `JAVA_PICO_HOME` to point to the extracted package location.
31
+
32
+
For example if you extracted the package to `/opt/pjvm-X.Y.Z` you will need to setup the variable with the following command :
33
+
34
+
```
35
+
export JAVA_PICO_HOME=/opt/pjvm-X.Y.Z
36
+
```
37
+
38
+
You will also need [JDK 8](https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.html) to build application, currently the latest versions of Java are not supported.
39
+
40
+
## Building and running a Java application
41
+
42
+
To run a Java application on the [Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) you will need to flash the Java virtual machine itself and than flash the Java application at the address `0x10100000`.
16
43
17
44
Lets say we have a simple hello world application :
18
45
@@ -24,34 +51,52 @@ class Main {
24
51
}
25
52
```
26
53
27
-
The name of the class `Main` is currently fixed as the first class that is loaded by the VM. Compiler the class :
54
+
**NOTE : The name of the class `Main` is currently fixed as the first class that is loaded by the VM.**
Make sure to setup you environment correctly so that `JAVA_PICO_HOME` points to the right place (see [here](#installation-and-setup))
36
63
37
-
```
38
-
cd main.dir
39
-
jar -cfM0 ../main.jar .
40
-
```
64
+
2. Preverify the classes
41
65
42
-
Now we need to wrap the JAR with a header so we can run it on the Pi Pico :
66
+
Before running the compiled classes on the [Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) we will need to Preverify them. Preverifying is the process of post processing the class files so they can be run more efficiently on the target system. Preverifying is done with the `preverify` tool in the `bin` directory of the package.
Reboot your Pi Pico and you should see `Hello, World!` on your terminal
53
98
54
-
Reboot your Pi Pico and you should see `Hello, World!` on your terminal
99
+
This repository includes an `example` directory with a complete [Ant](https://ant.apache.org) `build.xml` for each example that runs all the above steps in a single command.
0 commit comments