title: How to set and get static variables from spark?
body: <p>I have a class as this:</p>
  <pre><code>public class Test {
      private static String name;
  
      public static String getName() {
          return name;
      }
  
      public static void setName(String name) {
          Test.name = name;
      }
  
      public static void print() {
          System.out.println(name);
      }
  
  }
  </code></pre>
  <p>Inside my Spark driver, I'm setting the name like this and calling the <code>print()</code> command:</p>
  <pre><code>public final class TestDriver{
  
      public static void main(String[] args) throws Exception {
          SparkConf sparkConf = new SparkConf().setAppName(&quot;TestApp&quot;);
          // ...
          // ...
          Test.setName(&quot;TestName&quot;)
          Test.print();
          // ...
      }
  }
  </code></pre>
  <p>However, I'm getting a <code>NullPointerException</code>. How do I pass a value to the global variable and use it?</p>