title: Pig Error: Could not find or load main class org.apache.pig.Main
body: <p>I am a beginner in PIG. </p>
  
  <p>I wrote a program following the WIKI to convert words in file to uppercase.</p>
  
  <p>--cat UPPER.java</p>
  
  <pre><code>package com.bigdata.myUdf;
  
  import java.io.IOException;
  import org.apache.pig.EvalFunc;
  import org.apache.pig.data.Tuple;
  import org.apache.pig.impl.util.WrappedIOException;
  
  public class UPPER extends EvalFunc&lt;String&gt; {
  
  public String exec(Tuple input) throws IOException {
      if (input == null || input.size() == 0)
      return null;
      try{
      String str = (String)input.get(0);
      return str.toUpperCase();
      }catch(Exception e){
      throw WrappedIOException.wrap("Caught exception processing input row ", e);
      }
      }
  
  }
  </code></pre>
  
  <p>-- cat /home/hduser/lab/mydata/myscript.pig</p>
  
  <pre><code>REGISTER /home/hduser/software/myUdfs/UPPER.jar
  std_det = LOAD '/pigdata/udf1.txt' USING PigStorage(',') as (name:chararray);
  B = FOREACH std_det GENERATE com.bigdata.myUdf.UPPER(name);
  dump B;
  </code></pre>
  
  <p>But when i run it I am getting Error.</p>
  
  <pre><code> java -cp com.bigdata.myUdf.UPPER.jar org.apache.pig.Main -x local /home/hduser/lab/mydata/myscript.pig
  </code></pre>
  
  <p>ERROR</p>
  
  <pre><code>Error: Could not find or load main class org.apache.pig.Main
  </code></pre>
  
  <p>cat .bashrc </p>
  
  <pre><code>export PIG_INSTALL=/home/hduser/software/pig
  export PATH="${PATH}:${PIG_INSTALL}/bin"
  export PIG_CLASSPATH=$HADOOP_CONF_DIR:${PIG_INSTALL}:.
  export CLASSPATH=.:${PIG_CLASSPATH}
  </code></pre>
  
  <p>The pig script is at:
      /home/hduser/lab/mydata/myscript.pig</p>
  
  <p>The JAR file is at:
      /home/hduser/software/myUdfs/UPPER.jar</p>
  
  <p>Please help me to understand what i am doing wrong. Thanks in advance.
   After following the instruction from Shivashakti. The program ran but it didnot give any output.</p>
  
  <pre><code> pig -x local myScript.pig
  
   15/01/05 04:47:57 INFO pig.ExecTypeProvider: Trying ExecType : LOCAL
  15/01/05 04:47:57 INFO pig.ExecTypeProvider: Picked LOCAL as the ExecType
  2015-01-05 04:47:57,920 [main] INFO  org.apache.pig.Main - Apache Pig version 0.14.0 (r1640057) compiled Nov 16 2014, 18:02:05
  2015-01-05 04:47:57,921 [main] INFO  org.apache.pig.Main - Logging error messages to:       /home/hduser/lab/piglog/pig_1420462077918.log
  2015-01-05 04:47:57,959 [main] INFO  org.apache.hadoop.conf.Configuration.deprecation - user.name is deprecated. Instead, use mapreduce.job.user.name
  2015-01-05 04:47:58,314 [main] INFO  org.apache.hadoop.conf.Configuration.deprecation - fs.default.name is deprecated. Instead, use fs.defaultFS
  2015-01-05 04:47:58,315 [main] INFO  org.apache.hadoop.conf.Configuration.deprecation - mapred.job.tracker is deprecated. Instead, use mapreduce.jobtracker.address
  2015-01-05 04:47:58,318 [main] INFO  org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at:   file:///
  2015-01-05 04:47:58,463 [main] INFO  org.apache.hadoop.conf.Configuration.deprecation -   fs.default.name is deprecated. Instead, use fs.defaultFS
  2015-01-05 04:47:59,070 [main] INFO  org.apache.hadoop.conf.Configuration.deprecation - fs.default.name is deprecated. Instead, use fs.defaultFS
  2015-01-05 04:47:59,227 [main] INFO  org.apache.pig.Main - Pig script completed in 2 seconds and 505 milliseconds (2505 ms)
  </code></pre>