@@ -266,12 +266,14 @@ async function runJavaFile(uri: vscode.Uri, noDebug: boolean) {
266266
267267 const hasMainMethods : boolean = mainMethods . length > 0 ;
268268 const canRunTests : boolean = await canDelegateToJavaTestRunner ( uri ) ;
269+ const defaultPlaceHolder : string = "Select the main class to run" ;
269270
270271 if ( ! hasMainMethods && ! canRunTests ) {
271272 const mainClasses : IMainClassOption [ ] = await utility . searchMainMethods ( ) ;
272- await launchMain ( mainClasses , uri , noDebug ) ;
273+ const placeHolder : string = `The file '${ path . basename ( uri . fsPath ) } ' is not executable, please select a main class you want to run.` ;
274+ await launchMain ( mainClasses , uri , noDebug , placeHolder , false /*autoPick*/ ) ;
273275 } else if ( hasMainMethods && ! canRunTests ) {
274- await launchMain ( mainMethods , uri , noDebug ) ;
276+ await launchMain ( mainMethods , uri , noDebug , defaultPlaceHolder ) ;
275277 } else if ( ! hasMainMethods && canRunTests ) {
276278 await launchTesting ( uri , noDebug ) ;
277279 } else {
@@ -282,7 +284,7 @@ async function runJavaFile(uri: vscode.Uri, noDebug: boolean) {
282284 { placeHolder : "Please select which kind of task you would like to launch" } ,
283285 ) ;
284286 if ( choice === launchMainChoice ) {
285- await launchMain ( mainMethods , uri , noDebug ) ;
287+ await launchMain ( mainMethods , uri , noDebug , defaultPlaceHolder ) ;
286288 } else if ( choice === launchTestChoice ) {
287289 await launchTesting ( uri , noDebug ) ;
288290 }
@@ -302,14 +304,15 @@ async function launchTesting(uri: vscode.Uri, noDebug: boolean): Promise<void> {
302304 noDebug ? vscode . commands . executeCommand ( "java.test.editor.run" , uri ) : vscode . commands . executeCommand ( "java.test.editor.debug" , uri ) ;
303305}
304306
305- async function launchMain ( mainMethods : IMainClassOption [ ] , uri : vscode . Uri , noDebug : boolean ) : Promise < void > {
307+ async function launchMain ( mainMethods : IMainClassOption [ ] , uri : vscode . Uri , noDebug : boolean , placeHolder : string ,
308+ autoPick : boolean = true ) : Promise < void > {
306309 if ( ! mainMethods || ! mainMethods . length ) {
307310 vscode . window . showErrorMessage (
308311 "Error: Main method not found in the file, please define the main method as: public static void main(String[] args)" ) ;
309312 return ;
310313 }
311314
312- const pick = await mainClassPicker . showQuickPickWithRecentlyUsed ( mainMethods , "Select the main class to run." ) ;
315+ const pick = await mainClassPicker . showQuickPickWithRecentlyUsed ( mainMethods , placeHolder , autoPick ) ;
313316 if ( ! pick ) {
314317 return ;
315318 }
0 commit comments