How do I check if the Java JDK is installed on Mac?

前端 未结 9 685
误落风尘
误落风尘 2021-01-29 21:48

How do you check if Java SDK is installed on a Mac?

Is there a command line for this?

相关标签:
9条回答
  • 2021-01-29 22:27

    Make sure you correctly define the project's JDK and restart IntelliJ (full restart).

    0 讨论(0)
  • 2021-01-29 22:29
    • Open terminal.
    • run command to see:

      javac -version

    • Also you can verify manually by going to the specific location and then check. To do this run below command in the mac terminal

      cd /Library/Java/JavaVirtualMachines/

    Then run ls command in the terminal again. Now you can see the jdk version & package if exists in your computer.

    0 讨论(0)
  • 2021-01-29 22:31

    If you are on Mac OS Big Sur, then you probably have a messed up java installation. I found info on how to fix the issue with this article: https://knasmueller.net/how-to-install-java-openjdk-15-on-macos-big-sur

    1. Download the .tar.gz file of the JDK on https://jdk.java.net/15/
    2. Navigate to the download folder, and run these commands (move the .tar.gz file, extract it and remove it after extraction):
    sudo mv openjdk-15.0.2_osx-x64_bin.tar.gz /Library/Java/JavaVirtualMachines/
    cd /Library/Java/JavaVirtualMachines/
    sudo tar -xzf openjdk-15.0.2_osx-x64_bin.tar.gz
    sudo rm openjdk-15.0.2_osx-x64_bin.tar.gz
    

    Note: it might be 15.0.3 or higher, depending on the date of your download.

    1. run /usr/libexec/java_home -v15 and copy the output
    2. add this line to your .bash_profile or .zshrc file, depending on which shell you are using. You will probably have only one of these files existing in your home directory (~/.bash_profile or ~/.zshrc).
    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home
    
    1. save the changes and make them effective right away by running: source ~/.bash_profile or source ~/.zshrc
    2. check that java is working - run java -v
    0 讨论(0)
提交回复
热议问题