Search code examples
javaintellij-ideajavac

how can i use different jdk for run and compile on IntelliJ?


I want to use zuluJDK for compile and AdoptJDK for run because of some reason.

but I can not find a way.

I've seen how to set compiler on Intellij web site. but there is no way to use different jdk for compile.

Even if i do not use IntelliJ, please let me know if there is a way to use other jdk in compiling and running


Solution

  • you mean compile with zuluJDK and run with AdoptJDK?

    1. open project structure settings(Ctrl+Alt+Shift+S) and change sdk to zuluJDK

    2. make jar or war file to run (compile and package)

    3. run jar as cmd with AdoptJDK

    e.g.

    cd C:\Program Files :: x86)\Java\jre1.8.0_321\bin (AdoptJDK installed folder where include java.exe
    java -jar packged.jar