When a Java file is opened directly in the VS Code editor, without opening a folder or a workspace file, then the Explorer panel does not show, nor does it give an option to display, the Run Configuration section.
Steps to Reproduce
Do not have VS Code open with a folder or workspace prior to the following steps.
Install the Oracle Java extension (I've tried with v. 22.0.1)
Open a Java file containing a main method directly in VS Code using the Open menu action or from Finder/Explorer.
Alternatively, create a New Java file and write a main method.
Accept to trust the file or folder request from VS Code, if prompted.
Notice that after analysis by the Java extension, the editor shows a Run main | Debug main action shortcut above the main method in the Java file.
This shortcut shows only when the extension setting for Editor: Enable Shortcuts is turned on.
Check the Explorer panel for the Run Configuration section in order to add arguments, etc. for the application Run/Debug
It is not available
Impact
It is not possible to supply custom arguments, VM options, environment variables etc. to the Java application that would be launched when using the Run main | Debug main editor hint actions.
Workaround
Use the Run menu Add Configurations action to open the settings.json file and launch the application only via the Run menu.
Here add or edit a Java+: Launch Java Application configuration (ctrl+space shortcut on MacOS).
Add JSON key and values as needed:
args for arguments
vmArgs for VM options
env for environment variables
Alternatively, Open the folder (or the multi-folder code-workspace file) containing the main Java file, before editing or attempting to run/debug the application or test it contains.
Fix Request
The Run Configuration section should be made available in the VSCode Explorer panel for non-workspace opened Java files too.
This will help in quickly running single file Java code without setting up a separate test folder or workspace, or, perform manual JSON settings editing which only advanced users may do.
Summary
When a Java file is opened directly in the VS Code editor, without opening a folder or a workspace file, then the Explorer panel does not show, nor does it give an option to display, the Run Configuration section.
Steps to Reproduce
main
method directly in VS Code using the Open menu action or from Finder/Explorer.main
method.main
method in the Java file.Impact
It is not possible to supply custom arguments, VM options, environment variables etc. to the Java application that would be launched when using the Run main | Debug main editor hint actions.
Workaround
args
for argumentsvmArgs
for VM optionsenv
for environment variablesFix Request
The Run Configuration section should be made available in the VSCode Explorer panel for non-workspace opened Java files too. This will help in quickly running single file Java code without setting up a separate test folder or workspace, or, perform manual JSON settings editing which only advanced users may do.