最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Mac中确认是否已成功安装JDK

Mac crifan 1236浏览 0评论
折腾:
【未解决】Mac中用VSCode调试java代码
期间,参考:
How to Debug Java with VSCode | vscode-debug-specs
➜  java echo $JAVA_HOME
没设置JAVA_HOME
➜  java which java
/usr/bin/java
可以找到java
看看版本
➜  java java --version
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
➜  java java -v       
Unrecognized option: -v
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
➜  java java -V
Unrecognized option: -V
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
➜  java java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
是1.8.0_112
所以感觉是:
要么是加上JAVA_HOME
要么是:去mac中安装JDK
先去mac中确认,是否之前已安装成功JDK,如果没有,再去安装
另外:
Getting Started · Building a RESTful Web Service
也要求是:
“* JDK 1.8 or later”
Java SE – Downloads | Oracle Technology Network | Oracle
mac verify installed jdk
macos – How do I check if the Java JDK is installed on Mac? – Stack Overflow
➜  ~ javac -version
javac 1.8.0_112
➜  ~ which javac
/usr/bin/javac
好像就算是确认jdk已安装了。
去看看:
➜  ~ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.0_112, x86_64:    "Java SE 8"    /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
    1.7.0_79, x86_64:    "Java SE 7"    /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home


/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
➜  ~ which java_home
java_home not found
java – How to tell if JRE or JDK is installed – Stack Overflow
➜  ~ java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
➜  ~ javac -version
javac 1.8.0_112
去看看
➜  ~ ll /Library/Java/JavaVirtualMachines/
total 0
drwxr-xr-x  3 root  wheel    96B 10 20  2015 jdk1.7.0_79.jdk
drwxr-xr-x  3 root  wheel    96B 12 17  2016 jdk1.8.0_112.jdk
➜  ~ ll /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk
total 0
drwxrwxr-x  5 root  wheel   160B 10  1  2016 Contents
【总结】
此处,通过:
➜  ~ javac -version
javac 1.8.0_112
就可以确认已经安装了JDK了 -》 才会有javac编译器可用。
另外相关的:
➜  ~ java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
应该只算:确认已安装了JRE -》 所以有java可用-》能运行java的东西了。
更深入的:
想要找到当前系统中所安装的所有的java版本:
➜  ~ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.0_112, x86_64:    "Java SE 8"    /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
    1.7.0_79, x86_64:    "Java SE 7"    /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home


/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
可以看出有2个版本:
  • 1.8.0_112
  • 1.7.0_79

转载请注明:在路上 » 【已解决】Mac中确认是否已成功安装JDK

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
89 queries in 0.215 seconds, using 22.09MB memory