Skip to content

Commit dfa9462

Browse files
Add support to specify java executable (#1198)
This new optional option will allow to specify java executable path to use to execute the program. Co-authored-by: Jinbo Wang <[email protected]>
1 parent 200d1dd commit dfa9462

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,11 @@
379379
"description": "%java.debugger.launch.mainClass.description%",
380380
"default": ""
381381
},
382+
"javaExec": {
383+
"type": "string",
384+
"description": "%java.debugger.launch.javaExec.description%",
385+
"default": ""
386+
},
382387
"args": {
383388
"type": [
384389
"array",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"java.debugger.launch.projectName.description": "The preferred project in which the debugger searches for classes. There could be duplicated class names in different projects. This setting also works when the debugger looks for the specified main class when launching a program. It is required for expression evaluation.",
33
"java.debugger.launch.mainClass.description": "The fully qualified class name (e.g. [java module name/]com.xyz.MainApp) or the java file path of the program entry.",
4+
"java.debugger.launch.javaExec.description": "The path to java executable to use. If unset project JDK's java executable is used.",
45
"java.debugger.launch.args.description": "The command line arguments passed to the program.",
56
"java.debugger.launch.vmArgs.description": "The extra options and system properties for the JVM (e.g. -Xms<size> -Xmx<size> -D<name>=<value>).",
67
"java.debugger.launch.modulePaths.description": "The modulepaths for launching the JVM. If not specified, the debugger will automatically resolve from current project.",

src/configurationProvider.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,17 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
295295
});
296296
}
297297

298-
config.javaExec = await lsPlugin.resolveJavaExecutable(config.mainClass, config.projectName);
298+
if (_.isEmpty(config.javaExec)) {
299+
config.javaExec = await lsPlugin.resolveJavaExecutable(config.mainClass, config.projectName);
300+
} else {
301+
if (!fs.existsSync(config.javaExec)) {
302+
throw new utility.UserError({
303+
message: "Java executable file path cannot be accessed, please specify a valid path in the launch.json.",
304+
type: Type.USAGEERROR,
305+
});
306+
}
307+
}
308+
299309
// Add the default launch options to the config.
300310
config.cwd = config.cwd || _.get(folder, "uri.fsPath");
301311
if (Array.isArray(config.args)) {

0 commit comments

Comments
 (0)