Question

I'm attempting to copy the file StandardQuestions.csv to a new filename with the following code:

String standardQuestions = "StandardQuestions.csv";
if(new File(standardQuestions).exists()){
    try{
        Path source = new File(standardQuestions).toPath();
        Path dest = new File(filename).toPath();
        Files.copy(source,dest);
    }
     catch(java.io.IOException e){JOptionPane.showMessageDialog(this,"Error: Input/Output exception.");}
}

I get an error thrown on the line Path source = new File(standardQuestions).toPath(); My error message is NoSuchMethodError, method toPath not found in class File. How could the File class not have this method? The program runs correctly on 3-4 machines, but for one user, it always throws this error. Any idea what's causing this? Is there any additional information needed to answer this question?

Was it helpful?

Solution

Since Path and toPath() are relatively recent additions to the Java library (they've been added in Java 7), I'd make sure you are using the same version of Java across the machines.

OTHER TIPS

The first thing that comes up is that one user is running a significantly different version of Java. It might be particularly old or non-standard (GNU Classpath).

Have your user upgrade their Java installation version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top