title: How do I compile a Hive UDF
body: <p>I am trying to compile this UDF:</p>
  
  <pre><code>package com.dataminelab.hive.udf;
  import org.apache.hadoop.hive.ql.exec.UDF;
  import org.apache.hadoop.io.Text;
  import java.security.*;
  
  /**
   * Calculate md5 of the string
  */
  public final class Md5 extends UDF {
  
      public Text evaluate(final Text s) {
          if (s == null) {
              return null;
          }
          try {
              MessageDigest md = MessageDigest.getInstance("MD5");
              md.update(s.toString().getBytes());
              byte[] md5hash = md.digest();
              StringBuilder builder = new StringBuilder();
              for (byte b : md5hash) {
              builder.append(Integer.toString((b &amp; 0xff) + 0x100, 16).substring(1));
              }
              return new Text(builder.toString());
              } catch (NoSuchAlgorithmException nsae) {
              System.out.println("Cannot find digest algorithm");
              System.exit(1);
          }
          return null;
      }
  }
  </code></pre>
  
  <p>Trying to compile with:</p>
  
  <pre><code>javac Md5.java
  </code></pre>
  
  <p>But I get:</p>
  
  <pre><code>Md5.java:2: package org.apache.hadoop.hive.ql.exec does not exist
  import org.apache.hadoop.hive.ql.exec.UDF;
                                       ^
  Md5.java:3: package org.apache.hadoop.io does not exist
  import org.apache.hadoop.io.Text;
  </code></pre>
  
  <p>I assume these are in a jar file somewhere but I'm not sure where hadoop install them to so I can't add them to my classpath. Does anyone know the default location or how to find out?</p>