问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
package java;
import java.io.*;
public class demo {
// TODO Auto-generated method stub
public static void main(String[] args) {
try{
writFileTest();
}catch (Exception e){
}
}
private static void writFileTest() throws FileNotFoundException,
IOException {
// 创建文件对象
File file = new File("c:\a.txt");
// 创建文件输出流
FileOutputStream fos = new FileOutputStream(file);
fos.write('j');
fos.write('d');
fos.close();
}
}
运行结果及报错内容
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:659)
at java.lang.ClassLoader.defineClass(ClassLoader.java:758)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
Error: A JNl error has occurred, please check your installation and try again
A Java Exception has occurred.
我的解答思路和尝试过的方法
把java与javac运行版本调到一致
我想要达到的结果
还是一样