微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

找不到java.nio.file包

我的 java编译器找不到 java.nio.file包.考虑:
import java.nio.file.*;
public class Test {
    public static void main(String[] args) { 
        Path currentRelativePath = Paths.get("");
    }
}

编译

bash$javac Test.java

Test.java:1: package java.nio.file does not exist
import java.nio.file.*;
                ^
Test.java:5: cannot find symbol
symbol  : class Path
location: class Test
    Path currentRelativePath = Paths.get("");
    ^
Test.java:5: cannot find symbol
symbol  : variable Paths
location: class Test
    Path currentRelativePath = Paths.get("");
                               ^
3 errors

我正在使用Ubuntu 12.04,我想我已经安装了JDK 7(见:package java.nio.file does not exist)

bash$java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01,mixed mode)

解决方法

你完全可以使用java 1.7,但是javac 1.6甚至是1.5

也许你可以使用

sudo update-alternatives --config javac

配置它.如果不能选择1.7,那么需要升级JDK包.

原文地址:https://www.jb51.cc/java/122153.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐