title: Trying to open spark after installation and getting an error: Unable to find any JVMs matching version "1.8"
body: <p><strong>Description:</strong></p>
  
  <p>I installed spark on my MacBook following using <em>Homebrew</em>. I followed the instruction process from: <a href="https://www.tutorialkart.com/apache-spark/how-to-install-spark-on-mac-os/" rel="nofollow noreferrer">https://www.tutorialkart.com/apache-spark/how-to-install-spark-on-mac-os/</a>.  </p>
  
  <p>The step by step process included installing Java, followed by Scala and then Spark. Java and Scala got installed successful. Spark got installed successfully as well.  </p>
  
  <p>When I tried to verify spark installation using below input command, I ran into an error.  </p>
  
  <p><strong>Input command:</strong> <code>spark-shell</code></p>
  
  <p><strong>Expected Behavior:</strong> Expect Spark to start on terminal </p>
  
  <p><strong>Actual Behavior:</strong> I get this below error:  </p>
  
  <pre><code>Unable to find any JVMs matching version "1.8".
  WARNING: An illegal reflective access operation has occurred
  WARNING: Illegal reflective access by org.apache.spark.unsafe.Platform (file:/usr/local/Cellar/apache-spark/2.4.5/libexec/jars/spark-unsafe_2.11-2.4.5.jar) to method java.nio.Bits.unaligned()
  WARNING: Please consider reporting this to the maintainers of org.apache.spark.unsafe.Platform
  WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
  WARNING: All illegal access operations will be denied in a future release
  Exception in thread "main" java.lang.ExceptionInInitializerError
      at org.apache.hadoop.util.StringUtils.&lt;clinit&gt;(StringUtils.java:80)
      at org.apache.hadoop.security.SecurityUtil.getAuthenticationMethod(SecurityUtil.java:611)
      at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:273)
      at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:261)
      at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:791)
      at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:761)
      at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:634)
      at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2422)
      at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2422)
      at scala.Option.getOrElse(Option.scala:121)
      at org.apache.spark.util.Utils$.getCurrentUserName(Utils.scala:2422)
      at org.apache.spark.SecurityManager.&lt;init&gt;(SecurityManager.scala:79)
      at org.apache.spark.deploy.SparkSubmit.secMgr$lzycompute$1(SparkSubmit.scala:348)
      at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$secMgr$1(SparkSubmit.scala:348)
      at org.apache.spark.deploy.SparkSubmit$$anonfun$prepareSubmitEnvironment$7.apply(SparkSubmit.scala:356)
      at org.apache.spark.deploy.SparkSubmit$$anonfun$prepareSubmitEnvironment$7.apply(SparkSubmit.scala:356)
      at scala.Option.map(Option.scala:146)
      at org.apache.spark.deploy.SparkSubmit.prepareSubmitEnvironment(SparkSubmit.scala:355)
      at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:774)
      at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:161)
      at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:184)
      at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:86)
      at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:920)
      at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:929)
      at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
  Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 2
      at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3756)
      at java.base/java.lang.String.substring(String.java:1902)
      at org.apache.hadoop.util.Shell.&lt;clinit&gt;(Shell.java:52)
  
  </code></pre>
  
  <p><strong>What I tried:</strong> </p>
  
  <p>I tried to change JAVA_HOME using below commands:  </p>
  
  <pre><code>export JAVA_HOME=/usr/local/opt/java
  </code></pre>
  
  <p>Previous JAVA_HOME path was <code>/opt/anaconda3</code>. I can see that JAVA_HOME got changed to <code>usr/local/opt/java</code>.  </p>
  
  <p>I am still getting the error. Appreciate your answers/feedback. Thanks!!!</p>