0

Im getting >>> /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/bin/java Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.streams

package java.streams;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class WritingFiles {
  public static void main(String[] args) throws IOException {

    // Stream Connectivity
    File file =
        new File("/Users/qasim_lp/Downloads/LearnJava/src/main/resources/myTextFileCreated.txt");
    FileWriter fileWriter = new FileWriter(file);
    BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);

    // Writing inside the file
    bufferedWriter.write("First Line");
    bufferedWriter.newLine();
    bufferedWriter.write("Test");

    // Closing the stream
    bufferedWriter.close();
  }
}

Any help? :)

  • Does this answer your question? [why \`java.lang.SecurityException: Prohibited package name: java\` is required?](https://stackoverflow.com/questions/3804442/why-java-lang-securityexception-prohibited-package-name-java-is-required) – AMC Apr 10 '20 at 23:19

1 Answers1

0

Move your class to the package that is not reserved for the JDK classes. Use Refactor | Move in IntelliJ IDEA. You can't use java.streams normally, try something like com.company.blabla instead.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904