Support Questions

Find answers, ask questions, and share your expertise

Writing a UDF for Hive in JAVA: packages doe not exist

avatar
Contributor

Dear community,

I am writing a UDF in JAVA that I want to use with HIVE. I like the description in this post http://www.bmc.com/blogs/how-to-write-a-hive-user-defined-function-udf-in-java/# so that is what I am folowing.

The first lines of my function are :

 

package com.companyname.hive.udf;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.io.Text;

import java.math.BigInteger;

public final class FNV extends UDF{

...

Whan comping my function, I always get following errors:

package org.apache.hadoop.hive.ql.exec does not exist
import org.apache.hadoop.hive.ql.exec.UDF;
^
FNV.java:5: package org.apache.hadoop.hive.ql.exec does not exist
import org.apache.hadoop.hive.ql.exec.Description;
^
FNV.java:6: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.Text;
^
FNV.java:10: cannot find symbol
symbol: class UDF
public final class FNV extends UDF{
^

 

From what I find online, it seems that I should add the location of the jar files that are required (hadoop-core-1.2.1.jar and hive-exec-0.13.0.jar) to the CLASSPATH (jars are in /home/user on my linux system):

export CLASSPATH=/home/user/hive-exec-0.13.0.jar:/home/user/hadoop-core-1.2.1.jar 

However after doing this, I still get the same errors.

Any input would be greatly appreciated!

Thanks

1 ACCEPTED SOLUTION

avatar
Contributor

Note that this is solved. When I closed my shell and again executed the export CLASSPATH statement, the error did not occur anymore.

View solution in original post

1 REPLY 1

avatar
Contributor

Note that this is solved. When I closed my shell and again executed the export CLASSPATH statement, the error did not occur anymore.