Hadoop/Eclipse - Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FileSystem -
i'm trying run putmerge program hadoop in action chuck lam manning publishing. should pretty simple, i've had bunch of problems trying run it, , i've gotten error can't figure out. meanwhile, i'm running basic wordcount program no problem. i've spent 3 days on now. i've done research possibly can on this, , i'm lost.
ya'll have ideas?
program:
import java.io.ioexception; import org.apache.hadoop.conf.configuration; import org.apache.hadoop.fs.fsdatainputstream; import org.apache.hadoop.fs.fsdataoutputstream; import org.apache.hadoop.fs.filestatus; import org.apache.hadoop.fs.filesystem; import org.apache.hadoop.fs.path; public class putmerge { public static void main(string[] args) throws ioexception { configuration conf = new configuration(); filesystem hdfs = filesystem.get(conf); filesystem local = filesystem.getlocal(conf); path inputdir = new path(args[0]); path hdfsfile = new path(args[1]); try{ filestatus[] inputfiles = local.liststatus(inputdir); fsdataoutputstream out = hdfs.create(hdfsfile); (int i=0; i<=inputfiles.length; i++){ system.out.println(inputfiles[i].getpath().getname()); fsdatainputstream in = local.open(inputfiles[i].getpath()); byte buffer[] = new byte[256]; int bytesread = 0; while( (bytesread = in.read(buffer)) > 0) { out.write(buffer, 0, bytesread); } in.close(); } out.close(); } catch(ioexception e){ e.printstacktrace(); } } }
output error eclipse:
2015-04-09 19:45:48,321 warn util.nativecodeloader (nativecodeloader.java:<clinit>(62)) - unable load native-hadoop library platform... using builtin-java classes applicable exception in thread "main" java.lang.noclassdeffounderror: org/apache/hadoop/fs/filesystem @ java.lang.classloader.findbootstrapclass(native method) @ java.lang.classloader.findbootstrapclassornull(classloader.java:1012) @ java.lang.classloader.loadclass(classloader.java:413) @ java.lang.classloader.loadclass(classloader.java:411) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:357) @ java.lang.class.forname0(native method) @ java.lang.class.forname(class.java:344) @ java.util.serviceloader$lazyiterator.nextservice(serviceloader.java:370) @ java.util.serviceloader$lazyiterator.next(serviceloader.java:404) @ java.util.serviceloader$1.next(serviceloader.java:480) @ org.apache.hadoop.fs.filesystem.loadfilesystems(filesystem.java:2563) @ org.apache.hadoop.fs.filesystem.getfilesystemclass(filesystem.java:2574) @ org.apache.hadoop.fs.filesystem.createfilesystem(filesystem.java:2591) @ org.apache.hadoop.fs.filesystem.access$200(filesystem.java:91) @ org.apache.hadoop.fs.filesystem$cache.getinternal(filesystem.java:2630) @ org.apache.hadoop.fs.filesystem$cache.get(filesystem.java:2612) @ org.apache.hadoop.fs.filesystem.get(filesystem.java:370) @ org.apache.hadoop.fs.filesystem.get(filesystem.java:169) @ putmerge.main(putmerge.java:16)
about eclipse:
eclipse ide java developers version: luna service release 2 (4.4.2) build id: 20150219-0600
about hadooop:
hadoop 2.6.0 subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r e3496499ecb8d220fba99dc5ed4c99c8f9e33bb1 compiled jenkins on 2014-11-13t21:10z compiled protoc 2.5.0 source checksum 18e43357c8f927c0695f1e9522859d6a command run using /usr/local/hadoop-2.6.0/share/hadoop/common/hadoop-common-2.6.0.jar
about java:
java version "1.8.0_31" java(tm) se runtime environment (build 1.8.0_31-b13) java hotspot(tm) 64-bit server vm (build 25.31-b07, mixed mode)
about machine:
mac osx 10.9.5
java build path - external jars in library:
put in code
configuration configuration = new configuration(); configuration.set("fs.hdfs.impl",org.apache.hadoop.hdfs.distributedfilesystem.class.getname()); configuration.set("fs.file.impl",org.apache.hadoop.fs.localfilesystem.class.getname());