Compact source file

Create a compact source file in IntelliJ IDEA.

Compact source files were introduced in Java 25. To create a compact source file, right-click the Project tool window (or press ⌘N (macOS) / Alt+Ins (Windows/Linux)) and select New | Java Class. In the New Java Class popup, select the option Compact source file.

This compact source file is created in the root directory of your project, even if you create it from another package. IntelliJ IDEA automatically adds an instance main method void main() to the file.

Interested in JVM Development?

call to action image

Did you know there is another way to create a compact source file in IntelliJ IDEA?

Learn More


Related Resources

Add arguments
Add arguments
Add args to your main method.
Convert compact source file to class
Convert compact source file to class
Convert a compact source file to a class in IntelliJ IDEA.
Download a JDK
Download a JDK
Download or associate a JDK with your project.