idea选择java编译器错误
java编译器选择两种(ctrl+alt+s
弹出Setting
(搜索 java compiler
即可))
升级2019之后,这两种突然都不能使用.
选择eclipse之后
Error:java: Internal error:
java.lang.IllegalArgumentException
at org.eclipse.jdt.internal.compiler.tool.EclipseFileManager.handleOption(EclipseFileManager.java:758)
at java.compiler@11.0.3/javax.tools.ForwardingJavaFileManager.handleOption(ForwardingJavaFileManager.java:99)
at org.jetbrains.jps.javac.JpsJavacFileManager.handleOption(JpsJavacFileManager.java:318)
at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:71)
at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:460)
at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:330)
at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:255)
at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:213)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1324)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1004)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1071)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:965)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:794)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:376)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:139)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:288)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:121)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:228)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
选择javac之后
Error:java: System Java Compiler was not found in classpath:
java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.jetbrains.jps.builders.impl.java.JavacCompilerTool.createCompiler(JavacCompilerTool.java:74)
at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:51)
at org.jetbrains.jps.javac.ExternalJavacProcess.compile(ExternalJavacProcess.java:190)
at org.jetbrains.jps.javac.ExternalJavacProcess.access$300(ExternalJavacProcess.java:32)
at org.jetbrains.jps.javac.ExternalJavacProcess$CompilationRequestsHandler$1.run(ExternalJavacProcess.java:255)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
原因,坤坤猜想如下
图片来自网络(侵删)
系统中安装了多个java,所以出现一些问题.造成无法编译(再深入的原因坤坤也不知道了).
关键是如何解决.这里感谢老哥的解决方式:
https://blog.csdn.net/qq_38190111/article/details/90203902
网络上一般的解决方式是两种编译方式换着改.一般选择的是eclipse.但是如今两个都有问题
截图中的选项去掉.原因是,老哥解释如下
IDEA 会记住之前用的jdk 目录,当你使用的上一个版本的jdk 卸载删除之后,idea还是 有记录存在,会去找上个版本的javac 地址,这样就不好了呀,我们就不让他自己找,我指定你用啥,你就用啥,真 好,舒服了。。
坤坤感觉666.于是给了老哥点赞并评论666