Skip to content

parsing error java 25 Instance Main Methods compact source files #1318

@doogle-oss

Description

@doogle-oss

Java 25

Finalizes support for instance main methods and compact source files, simplifying the traditional main method requirements. This allows simpler program entry points without the boilerplate of public static void main(String[] args).

Instance Main Methods

Instance main methods use a void main() signature (or void main(String[] args)), where the JVM automatically creates an instance of the class before invoking it. These eliminate the need for static and public modifiers for basic programs, making Java more accessible for beginners. For example:

void main() {
    System.out.println("Hello, World!");
}

The Java launcher handles instantiation seamlessly.

Compact Source Files

Compact source files extend this by allowing executable code without an explicit class declaration, using .java files with just the main method. This works for single-file programs and supports implicit imports for common APIs. Oracle docs confirm this as a standard feature in Java 25.

it seems google-java-format intellij plugin throws parsing error for the file. Can this be fixed.

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions