Hive on macOS

When I run hive, I got error as below:

Exception in thread "main" java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/
at org.apache.hadoop.hive.ql.session.SessionState.(
at org.apache.hadoop.hive.ql.session.SessionState.(
at org.apache.hadoop.hive.cli.CliSessionState.(
at org.apache.hadoop.hive.cli.CliDriver.main(
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
at java.base/java.lang.reflect.Method.invoke(
at org.apache.hadoop.util.RunJar.main(

I’m wired about the error that cast class in different jdk versions, I have set JAVA_HOME in profile, why I still got this error?

I tested java version, it’s jdk1.8

wanghongmeng:2.3.1 gizmo$ java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

But when I checked jdk’s installed directory, I found /Library/Java/Home was linked to jdk9’s home, I never used jdk9, so I uninstalled jdk9, and linked /Library/Java/Home to jdk1.8’s home.

After this, problem solved.😀😀