Error Cannot Find Symbol Import Java.nio.file
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Cannot find package java.nio.file up vote 7 down vote favorite My java compiler cannot find the java.nio.file package. Consider: import java.nio.file.*; public class Test { public static void main(String[] args) { Path currentRelativePath = Paths.get(""); } } compiling with bash$ javac Test.java gives 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, and I think I have JDK 7 installed (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) java nio share|improve this question asked Nov 17 '13 at 9:42 Hakon Hægland 8,57352262 3 What do you see if you type javac -version ? –David Wallace Nov 17 '13 at 9:47 Check stackoverflow.com/questions/11338586/… –Sandhu Santhakumar Nov 17 '13 at 9:50 add a comment| 4 Answers 4 active oldest votes up vote 9 down vote accepted It is entirely possible that you have java 1.7, but javac 1.6 or even 1.5 maybe you can use sudo update-alternatives --config javac to configure it. If you cannot choose 1.7, then you need to upgrade your JDK package. share|improve this answer answered Nov 17 '13 at 9:47 ljgw 2,280628 Yes you are right.. I have for some reason javac vers
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: http://stackoverflow.com/questions/20029271/cannot-find-package-java-nio-file Sign up package java.nio.file does not exist up vote 4 down vote favorite 1 I'm working out how to compile java from command line at the moment. Here's what I've got: Here's what I've got: /myjava/compile.cmd /myjava/src/a_pack/HelloWorld.java /myjava/src/b_pack/Inner.java /myjava/src/b_pack/Inner2.java /myjava/bin HelloWorld: package a_pack; import b_pack.Inner; import b_back.Inner2; import java.util.ArrayList; import java.util.Iterator; public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, http://stackoverflow.com/questions/16577797/package-java-nio-file-does-not-exist World"); Inner myInner = new Inner(); myInner.myInner(); Inner2 myInner2 = new Inner2(); myInner2.myInner(); ArrayList myArray = new ArrayList(); myArray.add(1); myArray.add(2); myArray.add(3); Iterator itr = myArray.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); } } } Inner.java package b_pack; public class Inner { public void myInner() { System.out.println("Inner Method"); } } Inner2.java package b_pack; public class Inner2 { public void myInner() { System.out.println("SecondInner"); } } I'm compiling this with javac -d bin -sourcepath -src src/a_pack/HelloWorld.java and this works fine. Now my understanding is, that because the HelloWorld.java references the other packages in it's import statements, then javac goes and compiles those. And I'm guessing that for all the java packages, javac has them internally or something. Anyway - if I add the following import line to HelloWorld.java import java.nio.file.Files; it fails with D:\.....\myjava>javac -d bin -sourcepath src src/a_pack/HelloWo rld.java src\a_pack\HelloWorld.java:8: package java.nio.file does not exist import java.nio.file.Files; ^ 1 error What's the story here? Why are some java packages good and some not? java eclipse packages javac share|improve this question edited May 16 '13 at 2:55 asked May 16 '13 at 1:52 dwjohnston 60342048 2 NIO was intro
This Site Careers Other all forums Forum: Features new in Java 7 Possible issue with Java https://coderanch.com/t/560477/Java/java/Java 7 John Starr Greenhorn Posts: 3 posted 4 years ago I am working on this tutorial and having a few issues. Here is the problem "Create a file using any word-processing program or text editor. Write an application that displays the file's name, containing folder, size, error cannot and time of last modification. Save file as FileStatistics.java" Here is what I have: import java.nio.file.*; import java.nio.file.attribute.*; import java.nio.file.attribute.Attributes; import java.io.IOException; public class FileStatistics { public static void main(String[] args) { Path file = Paths.get("C:\\Java\\Chapter.13\\TestData.txt"); try { int count = file.getNameCount(); System.out.println("Path is " + file.toString()); error cannot find System.out.println("File name is " + file.getName()); System.out.println("Folder name is " + file.getName(count - 2)); BasicFileAttributes attr = Attributes.readBasicFileAttributes(file); System.out.println("File's size is " + attr.size()); FileTime time = attr.creationTime(); System.out.println("File's creation time is " + time); } catch(IOException e) { System.out.println("IO Exception"); } } } And this is the errors that I receive when I try to compile it: (I am using jGRASP) ----jGRASP exec: javac -g FileStatistics.java FileStatistics.java:3: error: cannot find symbol import java.nio.file.attribute.Attributes; ^ symbol: class Attributes location: package java.nio.file.attribute FileStatistics.java:15: error: method getName in interface Path cannot be applied to given types; System.out.println("File name is " + file.getName()); ^ required: int found: no arguments reason: actual and formal argument lists differ in length FileStatistics.java:18: error: cannot find symbol Attributes.readBasicFileAttributes(file); ^ symbol: variable Attributes location: class FileStatistics 3 errors ----jGRASP wedge2: exit code for process is 1. ----jGRASP: op