Skip to content

Package private Main class using Java 25 is not found by build plugins #47309

Closed

Description

@snicoll

I am working on a demo with Java 25 where you can define your main method as package private, i.e.

@SpringBootApplication
public class DemoApplication {

	static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

}

Trying to run or package the app leads to:

* What went wrong:
Execution failed for task ':bootJar'.
> Error while evaluating property 'mainClass' of task ':bootJar'.
   > Failed to calculate the value of task ':bootJar' property 'mainClass'.
      > Main class name has not been configured and it could not be resolved from classpath /Users/snicoll/workspace/demo/matchmaking/playerprofile/build/classes/java/main:/Users/snicoll/workspace/demo/matchmaking/playerprofile/build/resources/main

It looks like the algorithm should be relaxed now that the main method does not need to be public (at least on Java 25+)

Activity

  1. added
    status: waiting-for-triageAn issue that has not yet been triaged. Contributions will not be accepted.
    on Sep 24, 2025
  2. added and removed
    status: waiting-for-triageAn issue that has not yet been triaged. Contributions will not be accepted.
    on Sep 24, 2025
  3. added this to the 3.5.x milestone on Sep 24, 2025
  4. self-assigned this
    on Sep 24, 2025
  5. modified the milestones: 3.5.x, 3.5.7 on Sep 24, 2025
  6. added a commit that references this issue on Sep 24, 2025
    9a1d9f6
  7. mihaiapostol1995 commented on Jan 9, 2026

    @mihaiapostol1995

    Java 25 also allows this:

    public class SDMStoreApplication {
    
        void main() {
            SpringApplication.run(SDMStoreApplication.class);
        }
    }
    
    

    But it's causing the same exception as in this post. Can anyone please amend the spring-boot-loader-tools to remove the requirement on the main() method to be static? The issue seems to stem form here:

    Image
  8. snicoll commented on Jan 9, 2026

    @snicoll
    MemberAuthor

    See #35785

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions