diff --git a/vscode-wpilib/src/jdkdetector.ts b/vscode-wpilib/src/jdkdetector.ts index 83768a9a..f9d7d852 100644 --- a/vscode-wpilib/src/jdkdetector.ts +++ b/vscode-wpilib/src/jdkdetector.ts @@ -39,15 +39,31 @@ export function getJavaVersion(javaHome: string): Promise { export async function findJdkPath(api: IExternalAPI): Promise { // Check for java property, as thats easily user settable, and we want it to win - const vscodeJavaHome = vscode.workspace.getConfiguration('java').get('home'); + const vscodeJavaHome = vscode.workspace.getConfiguration('java').get('jdt.ls.java.home'); if (vscodeJavaHome) { try { const javaVersion = await getJavaVersion(vscodeJavaHome); if (javaVersion >= 17) { - logger.log(`Found Java Home Version: ${javaVersion} at ${vscodeJavaHome}`); + logger.log(`Found jdt.ls.java.home Version: ${javaVersion} at ${vscodeJavaHome}`); return vscodeJavaHome; } else { - logger.info(`Bad Java version ${javaVersion} at ${vscodeJavaHome}`); + logger.info(`Bad Java version ${javaVersion} at ${vscodeJavaHome} from jdt.ls.java.home Version`); + } + } catch (err) { + logger.log('Error loading java from jdt.ls.java.home, skipping', err); + } + } + + // Check for deprecated java property, as that was used before 2024 + const vscodeOldJavaHome = vscode.workspace.getConfiguration('java').get('home'); + if (vscodeOldJavaHome) { + try { + const javaVersion = await getJavaVersion(vscodeOldJavaHome); + if (javaVersion >= 17) { + logger.log(`Found Java Home Version: ${javaVersion} at ${vscodeOldJavaHome}`); + return vscodeOldJavaHome; + } else { + logger.info(`Bad Java version ${javaVersion} at ${vscodeOldJavaHome} from java.home`); } } catch (err) { logger.log('Error loading java from java.home, skipping', err); @@ -80,7 +96,7 @@ export async function findJdkPath(api: IExternalAPI): Promise