void () { String wslMsId = System.getProperty("wsl.distribution.name"); if (wslMsId == null) return; List<WSLDistribution> distributions = WslDistributionManager.getInstance().getInstalledDistributions(); if (distributions.isEmpty()) throw new IllegalStateException("no WSL distributions configured!"); myWSLDistribution = distributions.stream().filter(it -> wslMsId.equals(it.getMsId())).findFirst() .orElseThrow(() -> new IllegalStateException("Distribution " + wslMsId + " was not found")); String jdkPath = System.getProperty("wsl.jdk.path"); if (jdkPath == null) { jdkPath = "/usr/lib/jvm/java-11-openjdk-amd64"; } Sdk wslSdk = getWslSdk(myWSLDistribution.getWindowsPath(jdkPath)); WriteAction.runAndWait(() -> ProjectRootManagerEx.getInstanceEx(myProject).setProjectSdk(wslSdk)); assertTrue(new File(myWSLDistribution.getWindowsPath(myWSLDistribution.getUserHome())).isDirectory()); }