Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Java4GBA

From GameBrew
Revision as of 09:04, 13 December 2024 by HydeWing (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Java4gba
Java4gba02.png
General
AuthorTorlus
TypeOther Emulators
Version2004
LicenseMixed
Last Updated2004/01/05
Links
Download
Website
Source

Java4gba is an early port of KVM, Sun's Java Virtual Machine, part of CLDC 1.1 RI.

KVM is the Java VM you may find in mobile phones for running "Java games". This small work is only about CLDC, which means that there is nothing about graphics, sound, or whatever. You can only do some plain console output.

However, it brings to GBA almost all Java interesting features like Exceptions, Threading, Monitors. You will find some examples that illustrate these Java features.

Just reteun the examples.bat script to build some example ROMs (you don't necessarily need a Java compiler, but it is recommended, especially if you want to play with the VM.

User guide

If you are unfamiliar with J2ME (Java 2 Micro Edition), here is a small explanation about its architecture (roughly).

  KVM <------------  CLDC 1.1 <------------------ MIDP 2.0 <------------------ Java Game
   |                   |                              |                            |
the virtual        limited set of            more advanced set               running on top
machine            java classes              of classes featuring            of MIDP
                                             graphics, sound...

Some details about this port:

  • It has been compiled with "ROMizing" option, which means that all CLDC classes are already in the VM, so you don't need to add them in your GBFS file (see about GBFS below).
  • It has been compiled with KNI and float support, but the float support is broken. I still haven't tested the KNI part.
  • The VM heap size is 64K.
  • It uses GBFS, a GBA file system implementation by Damian Yerrick.
  • JAR support has been compiled in, but at the moment, you can't use it (see below).
  • The class verifier was disabled, which unexpectedly fails (even on "standard" platforms) when verifying some classes that perfectly works. I'll try to dig a bit around that.
  • In the code, almost all architecture-related stuff has been isolated. That means that it has basic implementations for about everything that you would expect from your operating system, or C library (memory allocation, file system...) functions. That also means that you can virtually port it on every kind of architecture.

Some functions come from code of Justin Armstrong's JaysOS.

The main difference between Java4gba and JaysOS is that JaysOS provides underlying functions allowing multiple programs (C or Waba ones) to run. Here Java4gba is only the Java Virtual Machine.

About GBFS

GBFS is a GBA file system implementation by Damian Yerrick. Basically, you create an archive containing your classes files, with the gbfs.exe tool provided, and you just append it to the kvm.bin file, to create your ROM (see the examples.bat file). So the basic steps to test your own Java programs are:

Compile them with a java compiler, example:

javac OneClass.java
javac OtherClass.java
javac MyMainClass.java

Create a GBFS archive with the .class files generated. The first class in the GBFS archive must be the one that contains the "main" function (protoype: public static void main(String [] args)), example:

gbfs.exe MyGBFSArchive.gbfs MyMainClass.class OneClass.class OtherClass.class

Finally append to the "kvm.bin" file, the GBFS archive you've just created, into a new file that will be your final ROM, example:

copy /b kvm.bin + MyGBFSArchive.gbfs MyJavaROM.bin

Important note - GBFS has some limitations:

  • The file names should not exceed 23 characters (".class" extension included).
  • There is no support for directories.

Credits

  • Damian Yerrick for his GBFS.
  • Justin Armstrong for his JaysOS.

External links

Advertising: