Question: I run a pig script in local mode and I can register directory that contains jars and all works fine:

```
register '/home/q/2/'

```

Wwile running exactly same script in mapreduce mode Im getting error as below:

```
        at org.apache.pig.PigServer.storeEx(PigServer.java:1034)
        ... 15 more
Caused by: java.io.FileNotFoundException: /var/tmp/home/q/2 (Is a directory)

```

Could you please advice how can i register dir while running in the mapreduce mode?

Answer: 
Try running the below command twice in either local or mapreduce mode:

*REGISTER '/home/q/2/'* ------- // Registering all jars in a directory.

On doing twice in same session, you will face this error the second time you register the folder:

**ERROR 2999: Unexpected internal error**

This is because the pig compiler doesn't understand two things : 

a. jars dependency resolution.

b. orders in which jars are to be imported.

**However**, if you specify the exact path of a jar while registering:

*REGISTER '/home/q/2/myudfs.jar'* ----------- // You can register jar like this "n" number of times.

Simply register each jar individually in your script either in local or map reduce mode.

This has the advantage as there are scenarios when your jars need to be imported in certain order because of dependency resolution issue.

For ex: twitter elephant bird project for working with Json data has several jars dependencies, so you need to import them in the correct order in Pig else you will always face such exceptions.
You should can do one of the flowing: 

* Upload your jar to hdfs and register it from there
* If you control the cluster then you can add it to the standard share lib