Reputation: 13
I am a beginner to java, and right now start learning Java IO API. However when I run this simple BufferedWriter
program, I got this error
"A JNI error has occurred, please check your installation and try again"
package java.io.demo;
public class BufferedWriterDemo {
public static void main(String[] args) {
String directory =System.getProperty("user.home");
String fileName ="sample.txt";
String absolutePath =directory + File.separator + fileName;
String text ="This is a text sample";
try {
BufferedWriter bufferedWriter =new BufferedWriter(new FileWriter(absolutePath));
bufferedWriter.write(text);
bufferedWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
I am using eclipse photon and java 8 JRE Screenshoot Any help?
Upvotes: 0
Views: 831
Reputation: 315
import java.io.* would work. But as per the error, you are showing shows you have an issue in your jdk installation. Please check your java version and JAVA_HOME path.
Upvotes: 1