Unable to find Java nio. File package
•
Java
My java compiler can't find Java nio. File package consider:
import java.nio.file.*; public class Test { public static void main(String[] args) { Path currentRelativePath = Paths.get(""); } }
compile
bash$javac Test.java
to
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
I am using Ubuntu 12.04. I think I have installed JDK 7 (see 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)
Solution
You can use Java 1.7, but javac 1.6 or even 1.5
Maybe you can use
sudo update-alternatives --config javac
Configure it If you cannot select 1.7, you need to upgrade the JDK package
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码