我不确定如何使用spark-submit
启动Java应用。
当我运行以下命令时:
spark@mcava-master:/home/miren/NetBeansProjects$ /opt/spark/bin/spark-submit --class /home/miren/NetBeansProjects/SparkExample/src/main/java/com/mycompany/sparkexample/CountWords.java --master spark://192.168.1.105:7077 /home/miren/NetBeansProjects/SparkExample/target/SparkExample-1.0-SNAPSHOT.jar spark://192.168.1.105:7077
我得到一个例外:
java.lang.ClassNotFoundException: /home/miren/NetBeansProjects/SparkExample/src/main/java/com/mycompany/sparkexample/CountWords.java
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.spark.util.Utils$.classForName(Utils.scala:174)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:689)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
如何指明类路径?
答案 0 :(得分:11)
您需要通过以下方式致电spark-submit
:
spark-submit --class com.mycompany.sparkexample.CountWords
--master spark://192.168.1.105:7077
/home/miren/NetBeansProjects/SparkExample/target/SparkExample-1.0-SNAPSHOT.jar
{your-app-arguments-here}
--class
参数获取包含主方法的对象的fully qualified name。
documentation包含有关正确使用spark-submit
的更多信息。