Hadoop on Mac with intellij idea-2 resolving URI errors resulting in permission denied

Source: Internet
Author: User

This article describes how to use filesystem. copyfromlocalfile in intellij idea to operate hadoop. Permission denied is caused by incorrect URI format.

Environment: Mac OS X 10.9.5, intellij idea 13.1.4, hadoop 1.2.1

Hadoop is stored in a virtual machine. The host machine is connected through SSH, And the IDE and data files are stored in the host machine.

The operation code is as follows:

1 public class copyfromlocaltestdriver {2 public static void main (string [] ARGs) {3 configuration = new configuration (); 4 try {5 filesystem = filesystem. get (New uri ("hadoopalice"), configuration); 6 7 path DST = New Path ("/D1 /"); 8 path src = New Path ("/users/Michael/desktop/hadoop/books/easyhadoop .doc"); 9 10 filesystem. copyfromlocalfile (SRC, DST); 11 12 Boolean exists = filesystem. exists (New Path ("/D1/easyhadoop .doc"); 13 system. out. println ("file easyhadoop .doc exists status:" + exists); 14} catch (ioexception e) {15 E. printstacktrace (); 16} catch (urisyntaxexception e) {17 E. printstacktrace (); 18} 19} 20}

Corresponding directories are also available in hadoop.

Prompt for execution

Well, you bullied me. It must be. The previous figure shows that I have access permissions.

Okay, that is to say, the problem should not be on hadoop. Check the code again.

Line 3 of the Code does not seem to comply with the URI rules when constructing a URI. According to section 7 of chapter 7 of "URI section" of elliotte Rusty Harold. Java Network Programming 3rd edition

A URI reference consists of three parts: pattern, pattern-specific, and fragment identifier. The general format is:

Scheme: Scheme-specific-part: Fragment

Compare the filesystem = filesystem. Get (New uri ("hadoopalice"), configuration) in row 5th. If the pattern part is missing, it is a relative Uri. For convenience, add the mode to solve this problem simply and rudely, and continue to learn later.

Filesystem = filesystem. Get (New uri ("HDFS: // hadoopalice: 9000"), configuration );

Run the command again. The result is as follows:

Query hadoop and find that the file is indeed submitted.

 

Hadoop on Mac with intellij idea-2 resolving URI errors resulting in permission denied

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.