How to import org.apache Java dependencies w/ or w

2019-01-17 22:53发布

So the quick background is I am creating a java program, that uses many different imports

    import org.apache.hadoop.conf.*;
    import org.apache.hadoop.fs.Path;
    import org.apache.hadoop.io.*;
    import org.apache.hadoop.mapreduce.*;
    import org.apache.hadoop.util.*;
    import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
    import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

I know that Netbeans isn't finding these files because I do not have them on my computer. But is there a way to have Netbeans automatically connect with org.apache and retrieve these files? Or do I just have to go and download them. Someone recommended using Maven, but I am not sure if this is the right solution or how to go about that?

Thanks

7条回答
We Are One
2楼-- · 2019-01-17 23:34

I have final figured out my preferred way to create a new Hadoop project and import the dependencies using Maven.

Using NetBeans I create a new Maven project.

Then under project files, I open the pom.xml.

I finally add inside of

    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-core</artifactId>
        <version>0.20.2</version>
    </dependency> 

After building with dependencies I am now ready to code.

查看更多
登录 后发表回答