title: Error initializing SparkContext:SparkException
body: <p>I am running the below spark-java code.</p>
  
  <pre><code>import org.apache.spark.SparkConf;
  import org.apache.spark.api.java.JavaSparkContext;
  import org.apache.spark.sql.hive.HiveContext;
  import org.apache.spark.sql.DataFrame;
  import org.apache.spark.sql.SQLContext;
  import org.apache.hadoop.fs.*;
  public class Resource{
  public static void main(String[] args) {
  SparkConf conf = new SparkConf().setAppName("cust data");
  JavaSparkContext jsc = new JavaSparkContext(conf);
  HiveContext hiveSQLContext = new    org.apache.spark.sql.hive.HiveContext(jsc.sc());
  DataFrame df = hiveSQLContext.sql(" select * from emprecord");
  df.registerTempTable("mytempTable");//creating temptable
  hiveSQLContext.sql("create table xyz as select * from mytempTable");//inserting into hie table
  jsc.close(
  }
  }
  </code></pre>
  
  <h1>Compile snippet as below:</h1>
  
  <pre><code> [harsha@hdp-poc1 SparkworkingJars]$ javac -cp $CLASSPATH Resource.java
  warning: /home/harsha/SparkworkingJars/spark-core_2.11-    1.6.1.jar(org/apache/spark/api/java/JavaSparkContextVarargsWorkaround.class):     major version 51 is newer than 50, the highest major version supported by this    compiler.
  It is recommended that the compiler be upgraded.1 warning
  </code></pre>
  
  <h1>RUN snippet as below:</h1>
  
  <pre><code>    [harsha@hdp-poc1 SparkworkingJars]$ java -cp $CLASSPATH Resource
  16/05/24 10:50:04 INFO spark.SparkContext: Running Spark version 1.6.1
  16/05/24 10:50:05 WARN util.NativeCodeLoader: Unable to load native-hadoop     library for your platform... using builtin-java classes where applicable
  16/05/24 10:50:05 ERROR spark.SparkContext: Error initializing SparkContext.
  org.apache.spark.SparkException: A master URL must be set in your     configuration
      at org.apache.spark.SparkContext.&lt;init&gt;(SparkContext.scala:401)
      at org.apache.spark.api.java.JavaSparkContext.&lt;init&gt;    (JavaSparkContext.scala:59)
      at Resource.main(Resource.java:15)
      16/05/24 10:50:05 INFO spark.SparkContext: Successfully stopped SparkContext
      Exception in thread "main" org.apache.spark.SparkException: A master URL     must be set in your configuration
      at org.apache.spark.SparkContext.&lt;init&gt;(SparkContext.scala:401)
      at org.apache.spark.api.java.JavaSparkContext.&lt;init&gt;    (JavaSparkContext.scala:59)
      at Resource.main(Resource.java:15)
  </code></pre>
  
  <p>Please help me resolving the issue related to org.apache.spark.SparkException .</p>