Skip to content

Commit 13fe1de

Browse files
Use User's specified java home to launch debuggee (#225)
Signed-off-by: Jinbo Wang <[email protected]>
1 parent b3a2e74 commit 13fe1de

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugSettings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public final class DebugSettings {
2626
public boolean showHex = false;
2727
public boolean enableHotCodeReplace = false;
2828
public String logLevel;
29+
public String javaHome;
2930

3031
public static DebugSettings getCurrent() {
3132
return current;

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugUtility.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ public static IDebugSession launch(VirtualMachineManager vmManager,
163163
arguments.get(ENV).setValue(encodeArrayArgument(envVars));
164164
}
165165

166+
if (StringUtils.isNotEmpty(DebugSettings.getCurrent().javaHome)) {
167+
arguments.get(HOME).setValue(DebugSettings.getCurrent().javaHome);
168+
}
169+
166170
VirtualMachine vm = connector.launch(arguments);
167171
// workaround for JDT bug.
168172
// vm.version() calls org.eclipse.jdi.internal.MirrorImpl#requestVM

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchRequestHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.commons.lang3.StringUtils;
3030

3131
import com.microsoft.java.debug.core.Configuration;
32+
import com.microsoft.java.debug.core.DebugSettings;
3233
import com.microsoft.java.debug.core.adapter.AdapterUtils;
3334
import com.microsoft.java.debug.core.adapter.ErrorCode;
3435
import com.microsoft.java.debug.core.adapter.IDebugAdapterContext;
@@ -99,7 +100,9 @@ protected static String[] constructLaunchCommands(LaunchArguments launchArgument
99100
String slash = System.getProperty("file.separator");
100101

101102
List<String> launchCmds = new ArrayList<>();
102-
launchCmds.add(System.getProperty("java.home") + slash + "bin" + slash + "java");
103+
final String javaHome = StringUtils.isNotEmpty(DebugSettings.getCurrent().javaHome) ? DebugSettings.getCurrent().javaHome
104+
: System.getProperty("java.home");
105+
launchCmds.add(javaHome + slash + "bin" + slash + "java");
103106
if (StringUtils.isNotEmpty(address)) {
104107
launchCmds.add(String.format("-agentlib:jdwp=transport=dt_socket,server=%s,suspend=y,address=%s", serverMode ? "y" : "n", address));
105108
}

0 commit comments

Comments
 (0)