|
1 | | -# Overview |
| 1 | +# GNU Classpath |
2 | 2 |
|
3 | | -This is a fork of the original GNU Classpath git repository. |
| 3 | +GNU Classpath is a set of core class libraries for use with Java Virtual Machines, providing roughly Java 1.6 (Java SE 6) API compatibility. |
| 4 | + |
| 5 | +## Why GNU Classpath |
| 6 | + |
| 7 | +GNU Classpath provides a lightweight alternative to OpenJDK for environments where a full JDK is unnecessary. Combined with a compact VM such as [JamVM](https://github.com/ingelabs/jamvm), it is well suited for embedded and resource-constrained devices, offering: |
| 8 | + |
| 9 | +- Smaller flash and RAM footprint |
| 10 | +- Lower startup overhead |
| 11 | +- Minimal impact on runtime performance for typical workloads |
| 12 | + |
| 13 | +This makes it a practical choice when deploying Java applications on hardware where the size and startup cost of a full OpenJDK installation is prohibitive. |
| 14 | + |
| 15 | +## Supported platforms |
| 16 | + |
| 17 | +The primary targets are Linux embedded systems. The following architectures are supported: |
| 18 | + |
| 19 | +- Linux / 32-bit ARM |
| 20 | +- Linux / 64-bit ARM (aarch64) |
| 21 | +- Linux / x86_64 |
| 22 | + |
| 23 | +macOS with Apple Silicon is also supported for development (not as a target). |
| 24 | + |
| 25 | +Other platforms supported by the build system may work but are not actively tested. |
| 26 | + |
| 27 | +## Building GNU Classpath |
| 28 | + |
| 29 | +### Prerequisites |
| 30 | + |
| 31 | +A Java 8 JDK is required to compile the class library. |
| 32 | + |
| 33 | +For Linux, Temurin or Zulu are good choices. For macOS, Zulu is recommended (Temurin is not available for Apple Silicon). |
| 34 | + |
| 35 | +Additional prerequisites for a typical headless configuration: |
| 36 | + |
| 37 | +**Linux (Debian/Ubuntu):** |
| 38 | + |
| 39 | +```sh |
| 40 | +sudo apt-get install build-essential autoconf automake libtool gettext texinfo |
| 41 | +``` |
| 42 | + |
| 43 | +**macOS:** |
| 44 | + |
| 45 | +```sh |
| 46 | +brew install autoconf automake libtool gettext texinfo |
| 47 | +``` |
| 48 | + |
| 49 | +You may need to link the gettext m4 macros into the aclocal directory (see [Homebrew#53192](https://github.com/Homebrew/homebrew-core/issues/53192)): |
| 50 | + |
| 51 | +```sh |
| 52 | +ln -sf "$(brew --prefix gettext)/share/gettext/m4/"*.m4 "$(aclocal --print-ac-dir)/" |
| 53 | +``` |
| 54 | + |
| 55 | +### Build |
| 56 | + |
| 57 | +```sh |
| 58 | +autoreconf -iv |
| 59 | +./configure \ |
| 60 | + --disable-gtk-peer \ |
| 61 | + --disable-gconf-peer \ |
| 62 | + --enable-default-preferences-peer=file \ |
| 63 | + --disable-examples \ |
| 64 | + --disable-tools \ |
| 65 | + --disable-gjdoc |
| 66 | +make |
| 67 | +sudo make install |
| 68 | +``` |
| 69 | + |
| 70 | +### Cross-compilation |
| 71 | + |
| 72 | +When building for embedded targets, a cross-compilation toolchain is needed. |
| 73 | + |
| 74 | +For building complete embedded Linux images, consider using tools such as [Buildroot](https://buildroot.org/) or [ptxdist](https://www.ptxdist.org/). |
| 75 | + |
| 76 | +## Building applications |
| 77 | + |
| 78 | +To compile a Java application against GNU Classpath, use `-bootclasspath` to point to the Classpath library classes, for example: |
| 79 | + |
| 80 | +```sh |
| 81 | +javac -source 1.6 -target 1.6 -bootclasspath /usr/local/classpath/share/classpath/glibj.zip HelloWorld.java |
| 82 | +``` |
| 83 | + |
| 84 | +This ensures the compiler only allows APIs provided by GNU Classpath. Any use of unsupported APIs will result in a compile-time error. |
| 85 | + |
| 86 | +## Running applications |
| 87 | + |
| 88 | +To run an application with [JamVM](https://github.com/ingelabs/jamvm): |
| 89 | + |
| 90 | +```sh |
| 91 | +jamvm HelloWorld |
| 92 | +``` |
| 93 | + |
| 94 | +JamVM automatically locates the GNU Classpath library classes from its installation prefix. |
| 95 | + |
| 96 | +## History |
| 97 | + |
| 98 | +This project is a fork of the original GNU Classpath project, which is no longer actively maintained (last release: 0.99, March 2012). |
4 | 99 |
|
5 | 100 | The original project site can be found here: https://www.gnu.org/software/classpath/ |
| 101 | + |
| 102 | +This fork continues development with a focus on embedded Linux targets. |
0 commit comments