Skip to content

mrjameshamilton/java-class-file-api-hello-world

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Java Class-File API Hello World

JEP 484 Class-File API (previously JEP 457 and JEP 466) 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:

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:

$ java Main.java

You can then execute the HelloWorld class file:

$ java HelloWorld
Hello World

Similar projects

There are many similar projects for parsing, generating, and transforming Java class files, including: