private static OSProcessHandler launchProcess(@NotNull Project project,
                                                @Nullable Module module,
                                                @Nullable Sdk alternateSdk) throws Exception{
    final Sdk sdk = alternateSdk != null? alternateSdk :
                    module != null? ModuleRootManager.getInstance(module).getSdk() :
                    ProjectRootManager.getInstance(project).getProjectSdk();
    if (sdk == null || !(sdk.getSdkType() instanceof JavaSdkType javaSdkType)) {
      throw new ExecException(
        (sdk != null ? "Expected Java SDK" : " SDK is not configured") +
        (module != null? " for module " + module.getName() : " for project " + project.getName())
      );
    }
    final JavaSdkVersion sdkVersion = JavaSdkVersionUtil.getJavaSdkVersion(sdk);
    if (sdkVersion == null) {
      throw new ExecException("Cannot determine version for JDK " + sdk.getName() + ". Please re-configure the JDK.");
    }
    if (!sdkVersion.isAtLeast(JavaSdkVersion.JDK_1_9)) {
      throw new ExecException("JDK version is " + sdkVersion.getDescription() + ". JDK 9 or higher is needed to run JShell.");
    }
    final String vmExePath = javaSdkType.getVMExecutablePath(sdk);
    if (vmExePath == null) {
      throw new ExecException("Cannot determine path to VM executable for JDK " + sdk.getName() + ". Please re-configure the JDK.");
    }
    final File executableFile = new File(vmExePath);
    final String frontEndPath = findFrontEndLibrary();
    if (frontEndPath == null) {
      throw new ExecException("Library " + JSHELL_FRONTEND_JAR + " not found in IDE classpath");
    }
    final GeneralCommandLine cmdLine = new GeneralCommandLine();
    cmdLine.setExePath(executableFile.getAbsolutePath());
    cmdLine.setWorkDirectory(executableFile.getParent());
    cmdLine.setCharset(ourCharset);
    if (DEBUG_PORT > 0) {
      cmdLine.addParameter("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=" + DEBUG_PORT);
    }

    final StringBuilder launchCp = new StringBuilder().append(frontEndPath);
    final String protocolJar = getLibPath(Endpoint.class);
    if (protocolJar != null) {
      launchCp.append(File.pathSeparator).append(protocolJar);
    }
    if (launchCp.length() > 0) {
      cmdLine.addParameter("-classpath");
      cmdLine.addParameter(launchCp.toString());
    }
    cmdLine.addParameter("com.intellij.execution.jshell.frontend.Main");

    // init classpath for evaluation
    //final Set<String> cp = new LinkedHashSet<>();
    //final Computable<OrderEnumerator> orderEnumerator = module != null ? () -> ModuleRootManager.getInstance(module).orderEntries()
    //                                                                   : () -> ProjectRootManager.getInstance(project).orderEntries();
    //ApplicationManager.getApplication().runReadAction(() -> {
    //  cp.addAll(orderEnumerator.compute().librariesOnly().recursively().withoutSdk().getPathsList().getPathList());
    //});

    //final File cpFile;
    //if (!cp.isEmpty()) {
    //  cpFile = FileUtilRt.createTempFile("_jshell_classpath_", "", true);
    //  try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cpFile), StandardCharsets.UTF_8))) {
    //    for (String path : cp) {
    //      writer.write(path);
    //      writer.newLine();
    //    }
    //  }
    //  cmdLine.addParameter("--@class-path");
    //  cmdLine.addParameter(cpFile.getAbsolutePath());
    //}
    //else {
    //  cpFile = null;
    //}

    final OSProcessHandler processHandler = new OSProcessHandler(cmdLine);
    //if (cpFile != null) {
    //  processHandler.addProcessListener(new ProcessAdapter() {
    //    @Override
    //    public void processTerminated(ProcessEvent event) {
    //      FileUtil.delete(cpFile);
    //    }
    //  });
    //}
    return processHandler;
  }
private static OSProcessHandler launchProcess(@NotNull Project project,
                                                @Nullable Module module,
                                                @Nullable Sdk alternateSdk)