score:0
put like this in your 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());
score:0
i had this problem when my maven repository contained corrupted jar files. same as you i could see the hadoop-common-x.x.x.jar existed in eclipse when viewing the "maven dependencies" of my java project. however when expanding the jar file in eclipse and selecting the class named org.apache.hadoop.fs.fsdatainputstream
eclipse was reporting a message something like "invalid loc header".
deleting all files from my local maven repository and executing mvn install
again resolved my issue
score:0
if you are using the configuration to run your app for debugging. make sure you have the checkbox checked for include dependencies with provided scope if you have any of the dependencies and you have mentioned its scope to provided. it worked for me by following this approach
score:1
my experience with eclipse ide :
my basic path for ubuntu installation is usr/hadoop/hadoop-2.7.1 (lets' say conf) i've added two jar files,from conf/share/hadoop/common/lib and from conf/share/hadoop/common. and this is the java code (from the book hadoop in action) :
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();
conf.set("fs.file.impl",org.apache.hadoop.fs.localfilesystem.class.getname());
org.apache.hadoop.fs.filesystem hdfs = org.apache.hadoop.fs.filesystem.get(conf);
filesystem local = org.apache.hadoop.fs.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);
for (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();
}
}
}
the solution for me was to export the .jar file from this code, and this what i did : right click on putmerge project, then export (from the pop-up menu) :
and saved the jar file in a folder named putmerge on home/hduser directory
in another folder named input (path /home/hduser/input) there are three .txt files as input for putmerge procedure :
and now we are ready to launch the command from a terminal session : hadoop jar /home/hduser/putmerge/putmerge.jar putmerge /home/hduser/input output4/all
and the command /usr/hadoop/hadoop-2.7.1$ hdfs dfs -cat /output4/all
will contain all the text of the three single files.
Source: stackoverflow.com
Related Query
- Exception in thread "main" java.lang.NoClassDefFoundError: Main in Eclipse on OSX 10.6
- Java Exception in thread main - ClassNotFoundException
- Exception in thread "main" java.lang.NullPointerException error - Eclipse Java linked lists
- Exception in thread "main" java.lang.OutOfMemoryError: Java heap space on eclipse
- Eclipse Java - Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
- Java Throws exception in thread main java.lang.NoClassDefFoundError
- App Engine UserService calls in servlet throw thread exception - Eclipse java
- Invoking Java main method with parameters from Eclipse
- Why do I get message: "Unhandled event loop exception Java heap space" in Eclipse when using javascript autocomplete?
- Eclipse debugging has dialog box: Exception processing async thread queue java.lang.NullPointerException
- Remove java exception breakpoints when debugging Liferay in eclipse
- Run multiple java main methods in eclipse
- Ant not working in Eclipse Kepler (Java Virtual Machine Launcher - A Java Exception has occured)
- Is it possible to use sysout without class and main method in Eclipse IDE using Java 9?
- How do you get Eclipse to auto-generate a main method for a new Java class?
- Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
- How to debug a plugin in Eclipse - i.e. a Java project without a Main method
- exception in thread main - java.util.InputMismatchException
- Export a Java project without main method (with external jars) to Jar in Eclipse
- Eclipse hangs forever, thread dump says Main thread is sleeping
- Hadoop - Exception in thread "main" java.lang.NullPointerException
- NoClassDefFoundError while trying to use jdk.incubator.http.HttpClient in java in Eclipse Oxygen
- NoClassDefFoundError exception when deploying dynamic web app from eclipse
- Java 9 Eclipse 4.7 Portable export error "resource not found", "Could not find main method from given launch configuration."
- Exception in thread "main" java.lang.SecurityException: Invalid signature file d igest for Manifest main attributes
- How to avoid no main class and no class def found error using DropBox and Eclipse for Java
- Eclipse : Java : OpenCV : "The import org cannot be resolved."
- Exception in thread "main" Error in Eclipse when trying to run TestNG class
- Java exception breakpoint with condition in Eclipse
- java servlet project and android library project in eclipse - NoClassDefFoundError
More Query from same tag
- Eclipse IDE for C/C++ Developers -> Download JDT
- Why is my ANTLR grammar file for Java not compiling?
- Helper to fix errors in Android Studio
- Java: terminated, exit value: -1073740940
- Do we have any (Eclipse ) opensource IDE support for Karaf +Camel Development
- Return false is not working in Java
- Java "constant string too long" compile error. Only happens using Ant, not when using Eclipse
- In latest eclipse version, I imported a project and this happened:
- Is there a way to weave jUnit tests with AspectJ being in two different projects?
- Tomcat won't allow me to send @POST requests using Jersey (Jax-RS)
- BIRT Report not running in eclipse after update to windows 8.1
- C++ preprocessor variable defined in project configuration in eclipse, but invisible to C++ indexer
- Java Classpath help
- ScalarFunctionMultiPageEditor cannot be found by Plug-in
- Eclipse 2019-09 R Cannot Install Tomcat 9
- My app keeps crashing in the emulator
- Why do I have to routinely Clean one particular project in Eclipse?
- Unable to download Glassfish tools for Eclipse Kepler?
- Installing Chrome Dev Tools in Eclipse - Debug Configurations missing config
- USB based eclipse project
- Eclipse dao component implement error
- The FileNotFoundException class appears to be missing from java.io?
- Error when open up Eclipse Juno
- When coding a quiz program, can I code each quiz in a separate project and add them at the end? Or must I create them in a one project from the start?
- Java search at a queue made of nodes
- ANTLR4 parse tree viewer in Eclipse
- method returning value in Java
- Java heap dump analysis tools keep crashing
- Java JMenu doesent work properly
- Why does M2Eclipse complain about missing artifact when mvn command line doesn't?