Develop iOS and Android apps in Java with a cross‑platform, minimal Java Virtual Machine. Run the same Java code on mobile and desktop with small binaries and low memory footprint.
Features
Architecture
Build for iOS/Android
Build for Windows/Linux/macOS
How to debug source
Using miniJVM in project
Documentation
License
- Builds on iOS / Android / mingw-w64 32|64-bit / MSVC 32|64-bit / macOS / Linux
- No external dependencies
- Minimal memory footprint
- Small binaries; embeddable JVM
- Minimal bootstrap class library — not a full JDK 8 implementation
- Supports Java source compilation (Janino)
- JIT support
- Low-latency Java garbage collection
- Remote debugging via JDWP
- Option to translate MiniJVM classes to C to improve execution speed
- OpenGL ES 3.0
- Swing‑like GUI library; HTML‑style XML layout
- Audio/Video playback and capture
- Take photos from camera or album
- Save and load files on the device
- API compatible with the desktop platform so apps run on desktop too
MiniJVM on the web, built by Starcommander. Source Web demo
2023.09 Rebound GLFW and GLFM graphics JNI bindings; moved GUI Java classes into the xgui package.
2022.11 Added documentation.
2021.03 Added j2c module — converts MiniJVM Java source to C and builds native applications for desktop and mobile.
2020.12 Added build scripts and released v2.1.
2020.10 Refactored source and removed binaries from the repository.
2020.10 Added HTTPS support.
2020.03 Added XML layout for the GUI system; fixed JDWP debugging for JetBrains IDEs.
2019.12 Bound cross‑platform AWTK UI system — see awtk-minijvm.
2019.12 Enabled JIT based on the SLJIT project.
2019.10 JIT in development.
2018.12 Optimized performance.
2017.09 Project started.
Write Java code once and run it on iOS / Android / macOS / Windows / Linux.
The essential JARs are not prebuilt; build them first.
Preferred IDEs: Eclipse, NetBeans, or JetBrains IntelliJ IDEA.
-
Run /binary/build_jar.sh or /binary/build_jar.bat to generate JARs.
OrBuild Maven project /minijvm/java; copy to /mobile/assets/resfiles/minijvm_rt.jar
Build Maven project /mobile/java/glfm_gui; copy to /mobile/assets/resfiles/glfm_gui.jar
Build Maven project /mobile/java/ExApp; copy to /mobile/assets/resfiles/ExApp.jar
Optionally modify /mobile/java/ExApp/src/main/java/test/MyApp.java; add resources to /mobile/java/ExApp/src/main/resource/res/ (audio, images, etc.); configure /mobile/java/ExApp/src/main/config.txt for icon, version, boot class, etc. -
In Xcode open /mobile/iosapp; set up your developer account in Signing & Capabilities; build and install to a device; verify the app before running (Settings → General → Device Management → {developer account} → Verify App → Trust).
-
In Android Studio open /mobile/androidapp; build and install to an Android device.
-
AppManager will run:
-
Run /binary/build_jar.sh or /binary/build_jar.bat to generate JARs.
OrBuild Java bootstrap classes in /minijvm/java; Maven build the JAR and copy to /binary/lib/minijvm_rt.jar
Build GUI classes /desktop/glfw_gui/java; Maven build the JAR and copy to /binary/libex/glfw_gui.jar
Build console test case classes /test/minijvm_test; Maven build the JAR and copy to /binary/libex/minijvm_test.jar
Build GUI test app classes /mobile/java/ExApp; Maven build the JAR and copy to /binary/{platform}/apps/ExApp.jar -
Run /binary/build_mac_linux.sh, /binary/build_wini686.bat, or /binary/build_winx64.bat to generate binaries.
OrBuild the GUI JNI C dynamic library in /desktop/glfw_gui/c with CMake
Build MiniJVM in /minijvm/c with CMake -
Run the test script /binary/{platform}/test.sh or test.bat
Almost all Java IDEs support remote debugging. The IDE connects to MiniJVM’s debug port over TCP and enters a debugging session. MiniJVM has two options: enable debugging, and suspend on start (wait for the IDE to attach before executing bytecode). Configure both options before initializing the VM.
These options are defined in jvm.h:
struct _MiniJVM {
...
s32 jdwp_enable;// 0: disable Java debug, 1: enable Java debug and disable JIT
s32 jdwp_suspend_on_start;
...
};
-
Enable MiniJVM debug mode; mini_jvm JDWP listens on port 8000.
Desktop: Run mini_jvm with -Xdebug, or change the source before building.
/minijvm/c/main.c: jvm->jdwp_enable = 1;
iOS/Android: change the source before building.
/mobile/c/glfmapp/main.c: refers.jvm->jdwp_enable = 1;
For device debugging, check the device IP address in Settings → Wi‑Fi → (i). -
Run the VM with jars eg:
mini_jvm.exe -Xdebug -bootclasspath ../lib/minijvm_rt.jar -cp ../libex/glfw_gui.jar org.mini.glfw.GlfwMain -
IDE open project , eg: /mobile/java/ExApp
IntelliJ IDEA: Run → Edit Configurations → + Remote; Transport: Socket; Debugger mode: Attach; host/port of your mini_jvm, e.g. "127.0.0.1:5005" or "192.168.0.32:5005".
Eclipse: configure similarly.
NetBeans: Debug → Attach Debugger; Connector: SocketAttach; host/port of your mini_jvm, e.g. "localhost:5005"; Timeout: 10000. -
Set breakpoints, pause the VM, and inspect variables.
Awtk-minijvm: AWTK cross‑platform native UI bound to MiniJVM.
LWJGUI-Mobile: Java LWJGL UI library.
BiBiX: Java instant messenger.
MiniJVM web demo: MiniJVM web demo.
Oracle CLDC: CLDC API reference.
OpenJDK: Java API reference.
Miniz: reading JAR files.
Glfm: cross‑platform (Android/iOS) GUI.
Nanovg: GUI rendering.
Stb: GUI TrueType fonts and images.
Glad: OpenGL/GLES header replacement.
Glfw: cross‑platform desktop GUI.
Dirent: Linux‑style file and directory access on Windows VC.
Tinycthread: cross‑platform threads.
JRegex: Java String regex matching.
Janino: compile Java source files.
MiniAudio: Java audio playback and capture.
Sljit: platform‑independent low‑level JIT compiler.
Mbedtls: HTTPS support via mbedtls.
Avian: Java API reference.
C / ObjC: JetBrains CLion, Xcode, Visual Studio
Swift: Xcode
Java: JetBrains IntelliJ IDEA, NetBeans
Android: Android Studio
Copy C sources from /minijvm/c into your project, and copy the built minijvm_rt.jar into your project’s resource folder.
#include "jvm/jvm.h"
int main(int argc, char **argv) {
char *bootclasspath = "../../binary/lib/minijvm_rt.jar";
char *classpath = "../../binary/libex/minijvm_test.jar;./";
char *main_name = "test.Foo3";
s32 ret = 1;
MiniJVM *jvm = jvm_create();
if (jvm != NULL) {
jvm->jdwp_enable = 0; //value 1 for java remote debug enable
jvm->jdwp_suspend_on_start = 0;
jvm->max_heap_size = 25 * 1024 * 1024; //
ret = jvm_init(jvm, bootclasspath, classpath);
if (ret) {
printf("[ERROR]minijvm init error.\n");
} else {
ret = call_main(jvm, main_name, NULL);
}
jvm_destroy(jvm);
}
return ret;
}
Project: Janino
Janino is a super-small, super-fast Java compiler.
Janino can not only compile a set of source files to class files like javac, but also compile a Java expression, a block, a class body, one .java file or a set of .java files in memory, load the bytecode and execute it directly in the same JVM. Janino is not a full Java compiler; see limitations, for example:
List<String> list=new ArrayList();
list.add("abc");
String s=(String)list.get(0);// cannot omit the (String) cast.
Download jars :
janino.jar
commons-compiler.jar
# compile /binary/res/BpDeepTest.java
mini_jvm -bootclasspath ../lib/minijvm_rt.jar -cp ../libex/janino.jar:../libex/commons-compiler.jar org.codehaus.janino.Compiler ../res/BpDeepTest.java
Project: Luaj
MiniJVM adapted: Luaj minijvm
Lightweight, fast, Java‑centric Lua interpreter written for JME and JSE, with string, table, package, math, io, os, debug, coroutine & luajava libraries, JSR‑223 bindings, all metatags, weak tables and unique direct Lua‑to‑Java‑bytecode compiling. Download JAR:
luaj.jar
mini_jvm -bootclasspath ../lib/minijvm_rt.jar -cp ../libex/luaj.jar Sample
| Windows mini_jvm GUI | macOS mini_jvm GUI | Linux mini_jvm GUI | Web mini_jvm GUI |
.
├── binary miniJVM binaries for build (win32/win64/mac/linux)
├── desktop
│ ├── awtk_gui open-source AWTK GUI JNI bindings
│ └── glfw_gui desktop OpenGL, GLFW, miniaudio, native module
├── j2c tools to translate MiniJVM Java source to C
│ ├── app
│ └── translator
├── minijvm Core source
│ ├── c MiniJVM C source
│ └── java miniJVM runtime library
├── mobile
│ ├── androidapp Android launcher
│ ├── assets app resources (fonts, JARs, images, audio, etc.)
│ ├── c mobile native libs: OpenGLES, GLFM framework, GUI JNI, glfmapp
│ ├── iosapp iOS launcher
│ └── java mobile Java lib, GUI, AppManager, example app
├── doc
└── test miniJVM test cases
License: MIT
Gust , digitalgust@163.com .








