码迷,mamicode.com
首页 > 编程语言 > 详细

Exception in thread "main" java.lang.NullPointerException

时间:2018-04-06 18:37:50      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:9.png   image   int   class   mission   解压缩   table   java   size   

1、在window操作系统上,使用eclipse开发工具从hdfs分布式文件系统上下载文件报空指针异常解决方法:

log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.NullPointerException
    at java.lang.ProcessBuilder.start(Unknown Source)
    at org.apache.hadoop.util.Shell.runCommand(Shell.java:482)
    at org.apache.hadoop.util.Shell.run(Shell.java:455)
    at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:702)
    at org.apache.hadoop.util.Shell.execCommand(Shell.java:791)
    at org.apache.hadoop.util.Shell.execCommand(Shell.java:774)
    at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:646)
    at org.apache.hadoop.fs.FilterFileSystem.setPermission(FilterFileSystem.java:472)
    at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:460)
    at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:426)
    at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:906)
    at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:887)
    at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:784)
    at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:365)
    at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:338)
    at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:289)
    at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1968)
    at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1937)
    at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1913)
    at com.bie.hadoop.crud.TextCreateNewFile.copyToLocalFile(TextCreateNewFile.java:191)
    at com.bie.hadoop.crud.TextCreateNewFile.main(TextCreateNewFile.java:239)

2、将hadoop-2.5.0-cdh5.3.6.tar.gz文件在window操作系统解压缩,配置好环境变量。

技术分享图片

技术分享图片

然后验证一下是否配置成功,操作如window+R,输入cmd:

 技术分享图片

然后将如下所示的文件hadoop-common-2.2.0-bin-32.rar解压缩,然后全部复制放到hadoop-2.5.0-cdh5.3.6.tar.gz的bin目录下面即可:

技术分享图片

最后重启电脑,运行下载程序,解决问题,或者在程序中配置如下所示内容:

System.setProperty("hadoop.home.dir","D:/biexiansheng/hadoop/hadoop-2.5.0-cdh5.3.6");

/***
 * 获取到配置信息
 * @return
 */
public static Configuration getConfiguration(){
    Configuration conf = new Configuration();
    conf.set("fs.defaultFS", "hdfs://192.168.19.131:9000");
    //重启机器或者设置这个值
    //System.setProperty("hadoop.home.dir","D:/biexiansheng/hadoop/hadoop-2.5.0-cdh5.3.6");
    return conf;
}

 

Exception in thread "main" java.lang.NullPointerException

标签:9.png   image   int   class   mission   解压缩   table   java   size   

原文地址:https://www.cnblogs.com/biehongli/p/8728295.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!