Tunggul Sagala
Tunggul Sagala

Reputation: 13

Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.io

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

Answers (1)

avdhesh
avdhesh

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

Related Questions