Java - How to pass the class of a generic type into a method
<p>The method in JavaSparkContext.newAPIHadoopRDD takes class as a parameter.  </p>

<p>In scala I was able to use the method like so:</p>

<pre><code>sc.newAPIHadoopRDD(job.getConfiguration,
      classOf[AvroKeyInputFormat[AvroFlumeEvent]],
      classOf[AvroKey[AvroFlumeEvent]],
      classOf[NullWritable])
</code></pre>

<p>How do i do that in java? </p>

<p>How do I pass the class of <code>AvroKeyInputFormat&lt;AvroFlumeEvent&gt;</code> into the method.</p>

<p>The closest I got was:</p>

<pre><code>        Class&lt;AvroKeyInputFormat&lt;AvroFlumeEvent&gt;&gt; inputFormatClass;
        Class&lt;AvroKey&lt;AvroFlumeEvent&gt;&gt; keyClass;

        JavaPairRDD&lt;AvroKey&lt;AvroFlumeEvent&gt;, NullWritable&gt; flumeEvents = sc.newAPIHadoopRDD(hadoopConf,
                inputFormatClass,
                keyClass,
                NullWritable.class);
</code></pre>

<p>However, now it is complaining that inputFormatClass may not have been initialized.  I think I'm missing something...</p>