You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot find main method for Maven project with subprojects #1006
Given a Maven project with subprojects, such as this one
And VSCode is open with the cwd set to the root of the project
And I open a file in one of the subprojects (e.g. XChartDemo.java)
And the language server starts successfully
And I wait for long enough for the project to be loaded
When I try to run the main method
Current Result
Then I get an error message:
Error: Main method not found in the file, please define the main method as: public static void main(String[] args)
Source: Debugger for Java (Extension)
I am having same trouble with running a single java file in a maven sub-project. Don't event think that this issue takes too long time to solved or I have to back to super-weight eclipse IDE.
Hope it will be solved soon.
Updated:
I found that the problem comes from jdk 11, which is the lowest version allowed by VS Code.
Since my project requires jdk 8.
I think there is no choice for me than bring the eclipse back.
Hi Marc Jakobi (@mrcjkb), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
Solution
Ensure you open the root folder of your multi-module Maven project (containing the parent pom.xml) as a workspace folder in VS Code, not just a single .java file. VS Code needs the full project structure to detect submodules and their main methods.
In the Java Projects or Maven explorer:
Click the Refresh button to re–import all modules.
Confirm that each subproject appears under Projects and that its src/main/java is marked as a source folder.
Once the modules are loaded, you should see Run | Debug codelenses above your public static void main(String[] args).
If it still doesn’t work:
Run Java: Clean the Java language server workspace (F1 → type Java: Clean).
Reload the window (F1 → Developer: Reload Window).
Check the Java Language Server logs for errors (F1 → Java: Open All Log Files).
A generic troubleshooting thread where missing code lenses are often caused by workspace setup issues. Suggests opening a clean workspace and sharing logs if the problem persists. cannot find main method #1207 (comment)
The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!
Install Community Server Connector and tomcat 8.5.50
set java home for Java Extension Pack and Community Server Connector in VS Code's settings.json:
"java.jdt.ls.java.home": "d:\\Apps\\jdk\\x64\\jdk-18.0.2", // java home for java extension pack
"rsp-ui.rsp.java.home": "D:\\Apps\\jdk\\x64\\jdk-11.0.18" // java home for Community Server Connector extension
Activity
ryno1234 commentedon Jul 3, 2022
Bump?
siebonguyen commentedon Jul 26, 2022
I am having same trouble with running a single java file in a maven sub-project. Don't event think that this issue takes too long time to solved or I have to back to super-weight eclipse IDE.
Hope it will be solved soon.
Updated:
I found that the problem comes from jdk 11, which is the lowest version allowed by VS Code.
Since my project requires jdk 8.
I think there is no choice for me than bring the eclipse back.
github-actions commentedon Nov 11, 2025
Hi Marc Jakobi (@mrcjkb), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
Solution
pom.xml) as a workspace folder in VS Code, not just a single.javafile. VS Code needs the full project structure to detect submodules and their main methods.src/main/javais marked as a source folder.public static void main(String[] args).Java: Clean).Other references with high confidence
The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!
mrcjkb commentedon Nov 11, 2025
I don't use vscode-java-debug anymore. Unsubscribing.
siebonguyen commentedon Nov 11, 2025
I successfully using Java Debug on VS Code:
What I have done: