1

I am doing a Friend Suggester application in Java using Hadoop 2.7.2 (latest atm) and I just finished the code. I want to compile the .java file and create the .class files but when I run the command

javac -d "/home/gramanas/" -cp "/srv/hadoop/share/hadoop/common/hadoop-common-2.7.2.jar:/srv/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.2.jar:/usr/lib/jvm/java-1.7.0-openjdk-amd64" FriendSuggest.java 

I get the following error:

FriendSuggest.java:63: error: 
error while writing FriendMapper: /home/gramanas/FriendSuggest$FriendMapper.class
    public static class FriendMapper
                  ^

I don't think it has something to do with the code since it compiles normally in IDEA. I want to compile it from command line but I can't get it to work.

What is the problem? How can I fix it?

Additional Info:

  • Ubuntu 16.04
  • Hadoop 2.7.2 pseudo distributed mode
  • java-1.7.0-openjdk-amd64
Cache Staheli
  • 3,510
  • 7
  • 32
  • 51
The Gramm
  • 118
  • 2
  • 12
  • Are you sure you have writing permissions in the path where the code is? Maybe try to move it elsewhere where you are sure. – Loris Securo May 03 '16 at 21:32
  • @LorisSecuro I feel stupid. But I was expecting a warning having to do with permission if that was the case. I used sudo and it compiled successfully. – The Gramm May 03 '16 at 21:36
  • In the future, please try to write a more informative question title, one that succinctly tells us exactly what your problem is, not a general complaint or plight. – Hovercraft Full Of Eels May 03 '16 at 21:37
  • Why exactly do you want to build from the command line? You can use Maven to build a JAR file for Hadoop to run – OneCricketeer May 03 '16 at 21:44
  • @cricket_007I follow https://hadoop.apache.org/docs/current/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html#Example:_WordCount_v1.0 and they use command line tools to build the jar. Plus i have no idea what maven is! I will learn it but not till i really need it :D – The Gramm May 03 '16 at 21:49
  • @HovercraftFullOfEels You have a point. I will try to be more specific next time. Do you have a suggestion for this question's title? – The Gramm May 03 '16 at 21:50
  • 1
    Don't use sudo unless you really need to. If you end up with files owned by root, you will see errors exactly like this. – Thorbjørn Ravn Andersen May 03 '16 at 22:45

1 Answers1

2

That type of error might be caused by not having writing permissions on the path you are executing the compilation.

You should try to compile where/when you are sure to have such permissions.

Loris Securo
  • 7,538
  • 2
  • 17
  • 28