Java – An error occurred while compiling Java with Hadoop

An error occurred while compiling Java with Hadoop… here is a solution to the problem.

An error occurred while compiling Java with Hadoop

java.io.FileSystem is not exposed in java.io; Not accessible from external packages
This is the line that the compiler points to

FileSystem fs = FileSystem.get(configuration);

I don’t understand why it can’t be accessed. This is an import

import java.io.*;
import java.io.FileSystem;
import java.nio.file.Paths;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.SequenceFile.Writer;
import org.apache.hadoop.io.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.*;
import java.util.*;
import java.io.Writer;
import org.apache.hadoop.*;

Solution

Bad FileSystem object and wrong Paths object. You want:

org.apache.hadoop.fs.FileSystem  
org.apache.hadoop.fs.Path

You are dealing with a Hadoop file system, not the default Java implementation. Recall that you executed hadoop fs -ls, where fs represents the file system on the command line.

Related Problems and Solutions