java - 找不到HibInputFormat类。找不到激励类Def

标签 java hadoop hipi

hduser@akshay-Lenovo-G580:~$ hadoop jar /home/hduser/HipiDemo.jar HelloWorld sampleimages.hib sampleimages_average Warning: $HADOOP_HOME is deprecated.

Exception in thread "main" java.lang.NoClassDefFoundError: org/hipi/imagebundle/mapreduce/HibInputFormat at HelloWorld.run(HelloWorld.java:44) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79) at HelloWorld.main(HelloWorld.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.hadoop.util.RunJar.main(RunJar.java:160) Caused by: java.lang.ClassNotFoundException: org.hipi.imagebundle.mapreduce.HibInputFormat at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 9 more



我的代码:
import hipi.image.FloatImage;

import java.io.IOException;

import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.hipi.image.HipiImageHeader;
import org.hipi.imagebundle.mapreduce.HibInputFormat;

public class HelloWorld extends Configured implements Tool {

public static class HelloWorldMapper extends Mapper<HipiImageHeader,     FloatImage, IntWritable, FloatImage> {
public void map(HipiImageHeader key, FloatImage value, Context context) 
  throws IOException, InterruptedException {
}
}
public static class HelloWorldReducer extends Reducer<IntWritable, FloatImage, IntWritable, Text> {
public void reduce(IntWritable key, Iterable<FloatImage> values, Context context) 
  throws IOException, InterruptedException {
}
}

public int run(String[] args) throws Exception {
  // Check input arguments
  if (args.length != 2) {
   System.out.println("Usage: helloWorld <input HIB> <output directory>");
    System.exit(0);
  }

  // Initialize and configure MapReduce job
  //Job job = Job.getInstance();
  Job job = new Job(getConf(), "Employee Salary");
 // Set input format class which parses the input HIB and spawns map tasks
job.setInputFormatClass(HibInputFormat.class);
// Set the driver, mapper, and reducer classes which express the computation
job.setJarByClass(HelloWorld.class);
job.setMapperClass(HelloWorldMapper.class);
job.setReducerClass(HelloWorldReducer.class);
// Set the types for the key/value pairs passed to/from map and reduce layers
job.setMapOutputKeyClass(IntWritable.class);
job.setMapOutputValueClass(FloatImage.class);
job.setOutputKeyClass(IntWritable.class);
job.setOutputValueClass(Text.class);

// Set the input and output paths on the HDFS
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));

// Execute the MapReduce job and block until it complets
boolean success = job.waitForCompletion(true);

// Return success or failure
return success ? 0 : 1;
 }

 public static void main(String[] args) throws Exception {
  ToolRunner.run(new HelloWorld(), args);
   System.exit(0);
}

}

最佳答案

将包含类HibInputFormat的jar添加到您的类路径中。

或者,如果在编译时使用行命令:
例如:
javac -classpath /lib/jarContainingTheClass.jar /examples/HelloWorld.java

关于java - 找不到HibInputFormat类。找不到激励类Def,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34559262/

相关文章:

java - Mahout - 尝试维基百科示例时出错

apache-spark - ApplicationMaster-在YARN中运行的不同类型的应用程序是否有所不同?

sql-server - 如何减少sqoop导出的日志大小

hadoop - 容器在 mapreduce 任务期间以非零退出代码 1 错误退出

java - 使用sdkman安装后如何设置gradle路径

java - concat Jolt 转换可在演示站点上运行;在代码中不起作用

java - 如何比较二维(或嵌套)Java 数组?

opencv - 从 hbase 读取图像并使用 Opencv 检测该图像中的人脸

java - 使用 LuaJava 从 Luafile 调用带有可变数字参数的 Java 方法

java - java中的 vector 排序