<dependencies>
<!-- Hadoop Core -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
@InterfaceAudience.Public
@InterfaceStability.Stable
public class ExampleClass {
@CustomAnnotation("This is a custom annotation")
public void exampleMethod() {
}
}
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface CustomAnnotation {
String value();
}
import org.apache.hadoop.util.GenericOptionsParser;
public class Main {
public static void main(String[] args) throws Exception {
GenericOptionsParser parser = new GenericOptionsParser(args);
ExampleClass example = new ExampleClass();
System.out.println("Example Method Annotation: " + example.getClass()
.getMethod("exampleMethod")
.getAnnotation(CustomAnnotation.class)
.value());
}
}
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/tmp/hadoop-${user.name}</value>
</property>
</configuration>
bash
$ java -cp <path-to-hadoop-libs>;<path-to-your-jar> Main