https://github.com/mrjameshamilton/java-class-file-api-hello-world
A Java Class-File API Hello World example
https://github.com/mrjameshamilton/java-class-file-api-hello-world
bytecode classfile java jep457 jvm
Last synced: 8 months ago
JSON representation
A Java Class-File API Hello World example
- Host: GitHub
- URL: https://github.com/mrjameshamilton/java-class-file-api-hello-world
- Owner: mrjameshamilton
- License: mit
- Created: 2023-10-03T19:56:36.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-09T09:23:27.000Z (10 months ago)
- Last Synced: 2025-03-28T22:07:31.315Z (9 months ago)
- Topics: bytecode, classfile, java, jep457, jvm
- Language: Java
- Homepage: https://jameshamilton.eu/programming/java-class-file-api-hello-world
- Size: 11.7 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Java Class-File API Hello World
[JEP 484 Class-File API](https://openjdk.org/jeps/484) (previously [JEP 457](https://openjdk.org/jeps/484) and [JEP 466](https://openjdk.org/jeps/484)) is an API introduced in Java 24 to provide a standard API for parsing,
generating, and transforming Java class files.
The example here shows how easy it is to use to create a
new class that prints "Hello World".
https://github.com/mrjameshamilton/jep457-hello-world/blob/ea854cda0e058d728630af907f9ed715d9a081ca/Main.java#L14-L19
# Building
You'll need JDK 24 and easiest way to install this on Linux is with [SDK man](https://sdkman.io/):
```shell
sdk install java 24.ea.36-open
```
If you have Java 24, you can execute the `Main.java` file which will produce a new class file `HelloWorld.class`:
```shell
$ java Main.java
```
You can then execute the `HelloWorld` class file:
```shell
$ java HelloWorld
Hello World
```
# Similar projects
There are many similar projects for parsing,
generating, and transforming Java class files, including:
* [ASM](https://asm.ow2.io/)
* [ProGuardCORE](https://github.com/Guardsquare/proguard-core)
* [ByteBuddy](https://bytebuddy.net/#/)