Issue
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? :)
Solution
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.
Answered By - CrazyCoder
Answer Checked By - Timothy Miller (JavaFixing Admin)