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
Filter out run and debug contextual menu when the file doesn't contain a Main #937
Run and debug contextual menu are available on files that cannot be run or debug. it would be better to not provide the menu. it will allow having a lighter contextual menu, do nto give false hope to end-users and avoid an error notifications when clicking on it
Environment
Operating System:
JDK version:
Visual Studio Code version:
Java extension version:
Java Debugger extension version:
Steps To Reproduce
create a java file which does not contain a Main class
right-click on it
[attach a sample project reproducing the error] attach logs
The contextual menu is added statically. To support filter out those files without a main method, we have to watch the file changes to dynamically calculate the main method info of the current file and update the menu registry.
Hi Aurélien Pupier (@apupier), 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.
Currently, the Java Debug extension registers Run/Debug on all *.java files regardless of containing a main method. There is no user-facing setting to hide these commands when no entry point exists.
A related discussion is in vscode-java-debug issue #1037, where it’s noted that menus are contributed on every Java file and then the debugger searches the workspace for main classes if none are in the current file.
To track or request filtering based on presence of a main method, please upvote or comment on that issue.
labels:
enhancement
duplicateUrls: []
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!
Activity
testforstephen commentedon Jan 20, 2021
The contextual menu is added statically. To support filter out those files without a main method, we have to watch the file changes to dynamically calculate the main method info of the current file and update the menu registry.
github-actions commentedon Nov 11, 2025
Hi Aurélien Pupier (@apupier), 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.
*.javafiles regardless of containing amainmethod. There is no user-facing setting to hide these commands when no entry point exists.mainmethod, please upvote or comment on that issue.labels:
duplicateUrls: []
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!