无法使用java命令运行Pig jar

无法使用java命令运行Pig jar,java,linux,hadoop,apache-pig,Java,Linux,Hadoop,Apache Pig,我试图简单的猪代码,但它给了我一些许可。 这是我的示例代码 import java.io.IOException; import org.apache.pig.PigServer; import org.apache.pig.ExecType; import org.apache.hadoop.conf.Configuration; public class PigTest{ public static void main(String[] args) { try {

我试图简单的猪代码,但它给了我一些许可。 这是我的示例代码

import java.io.IOException;
import org.apache.pig.PigServer;
import org.apache.pig.ExecType;
import org.apache.hadoop.conf.Configuration;
public class PigTest{
   public static void main(String[] args) {
   try {
        Configuration conf = new Configuration();
        conf.set("hdp.version","2.3.0.0-2557");
        //PigServer pigServer = new PigServer("mapreduce",conf);
        PigServer pigServer = new PigServer(ExecType.MAPREDUCE, conf);
     runIdQuery(pigServer, "myfile.txt");
   }
   catch(Exception e) {
   }
}
public static void runIdQuery(PigServer pigServer, String inputFile) throws IOException {
   pigServer.registerQuery("A = load '" + inputFile + "' using PigStorage(':');");
   pigServer.registerQuery("B = foreach A generate $0 as id;");
   pigServer.store("B", "idout");
   }
}
我将我的类路径设置如下

echo $CLASSPATH
.:/usr/hdp/2.3.0.0-2557/hadoop/client/*:/usr/hdp/2.3.0.0-2557/hadoop-hdfs/lib/*:/usr/hdp/2.3.0.0-2557/hadoop-mapreduce/lib/*:/usr/hdp/2.3.0.0-2557/hadoop-yarn/lib/*:/usr/hdp/2.3.0.0-2557/pig/lib/*:/usr/hdp/2.3.0.0-2557/hadoop/conf:/usr/hdp/2.3.0.0-2557/pig/pig-0.15.0.2.3.0.0-2557-core-h2.jar
当我用java命令运行代码时,它工作得很好,但当我创建了一个jar代码并试图运行时,它给了我以下权限错误

 ****java -cp /usr/hdp/2.3.0.0-2557/hadoop/client/*;/usr/hdp/2.3.0.0-2557/hadoop-hdfs/lib/*;/usr/hdp/2.3.0.0-2557/hadoop-mapreduce/lib/*;/usr/hdp/2.3.0.0-2557/hadoop-yarn/lib/*;/usr/hdp/2.3.0.0-2557/pig/lib/*;/usr/hdp/2.3.0.0-2557/hadoop/conf;/usr/hdp/2.3.0.0-2557/pig/pig-0.15.0.2.3.0.0-2557-core-h2.jar -jar PigTest.jar****


Error: Could not find or load main class .usr.hdp.2.3.0.0-2557.hadoop.client.activation.jar
-bash: /usr/hdp/2.3.0.0-2557/hadoop-hdfs/lib/asm-3.2.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/hadoop-mapreduce/lib/aopalliance-1.0.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/hadoop-yarn/lib/activation-1.1.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/pig/lib/accumulo-core-1.5.0.jar: Permission denied
-bash: /usr/hdp/2.3.0.0-2557/hadoop/conf: is a directory
-bash: /usr/hdp/2.3.0.0-2557/pig/pig-0.15.0.2.3.0.0-2557-core-h2.jar: Permission denied
如何修复此问题?

请尝试以下操作

  • 不要使用
    /usr/hdp/2.3.0.0-2557/hadoop/client/*
  • 用冒号(:)代替分号(;)。冒号用于在Linux上分隔路径
  • 如果上面的步骤1不起作用,请尝试将单个JAR放在路径中,而不是*.JAR