Skip to content

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

Closed as duplicate

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

​

Activity

  1. cushon commented on Jan 19, 2026

    @cushon
    Collaborator

    google-java-format doesn't support this yet, that is tracked by #1216

    Note that once support is added it will still need to be running on a JVM version that supports the new version, this is similar to #1278 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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