libjdk is a comprehensive C++ implementation of the Java Development Kit (JDK), providing native C++ libraries that mirror the functionality of Java's core libraries and modules. While it provides Java-like APIs, it runs as native C++ code without requiring a Java Virtual Machine.
This project provides a complete C++ implementation of Java's core functionality, including:
- Core Java Classes: Object, String, Integer, Boolean, Character, and all primitive wrapper classes
- Collections Framework: Complete collection interfaces and implementations including HashMap, ArrayList, LinkedList, HashSet, TreeMap, etc.
- I/O Operations: File handling, streams, and serialization
- Concurrency: Thread management and synchronization primitives
- Exception Handling: Complete exception hierarchy
- Reflection: Class introspection and dynamic method invocation
- Platform-specific Implementations: Native code for Windows, Linux, and macOS
- ✅ Cross-platform Support: Windows, Linux, and macOS
- ✅ CMake Build System: Modern, portable build configuration
- ✅ Comprehensive Testing: Extensive test suite included
- ✅ OpenJDK Compatible: Based on OpenJDK 17.35
- ✅ GPL Licensed: Free software with Classpath exception
java.base/
├── main/ # Main source code
│ ├── share/ # Platform-independent code
│ │ ├── classes/ # Java class implementations
│ │ ├── include/ # Header files
│ │ └── native/ # Native implementations
│ ├── windows/ # Windows-specific code
│ ├── linux/ # Linux-specific code
│ └── macos/ # macOS-specific code
├── test/ # Test suite
├── legal/ # Legal notices and licenses
└── CMakeLists.txt # Build configuration
This project includes several third-party libraries with appropriate licensing:
- OpenJDK: Core Java implementation (GPL v2 with Classpath exception)
- ICU: Internationalization support
- zlib: Compression library
- libffi: Foreign function interface
- ASM: Bytecode manipulation
- AES: Encryption support
- Unicode: Character set support
- CLDR: Locale data
- wepoll: Windows event polling
- CMake: Version 3.23 or higher
- C++ Compiler: Supporting C++17 or later
- Platform Support:
- Windows (x86_64, aarch64)
- Linux (x86_64, aarch64)
- macOS (x86_64, aarch64)
To build the example/helloworld project, follow these steps:
-
Clone java.base repository:
git clone https://github.com/libjdk/java.base.git
-
Create a build directory:
mkdir java.base.build
-
Run CMake to configure the java.base:
cmake -S java.base -B java.base.build -DCMAKE_BUILD_TYPE=Release
-
Build the java.base and install it to the repository:
cmake --build java.base.build --config Release --target install -j 8
#include <jcpp.h>
int main(int argc, char** argv) {
return $System::launch(argc, argv, nullptr, []($StringArray* args)->void {
$System::out->println("hello, world"_s);
});
}- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the GNU General Public License v2 with the Classpath exception, allowing linking with proprietary software. See the LICENSE file for details.
This project includes code from various open source projects. See the legal/ directory for detailed licensing information for each component.