Sample code JDK 21 project


As a teacher I'm very glad with JDK 21's feature of the simplified main method: “void main()” instead of “public static void main(String[] args)”, no class required. Now I don't have to explain anymore on day 1 of my class what class, public, static, and String[] args are.

However, when I create a new project in IntelliJ (with JDK 21) and I tick “Add sample code” the resulting Main class still contains the old-fashioned main, embedded in a class. The alternative is also bad: don't tick sample code but create a new Java class, delete “public class …”, and type “void main()”.

Any ideas how I can let my students create projects with as little cognitive overload as possible?


Hi Wiesman,

can you create a feature request at  []( and paste the link here? Then I'll help assign it to the right team.
Thank you. I've assigned it to the Java team developer. However, it might need some time to get it in the fix queue.

Please sign in to leave a comment.