线程“main”中的异常java.lang.IllegalArgumentException:PWC6309:非法compilerSourceVM:12

Huy*_*Huy 2 java jsp tomcat netbeans

我尝试运行下面的代码:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

但 IDE 向我显示错误:

Exception in thread "main" java.lang.IllegalArgumentException: PWC6309: Illegal compilerSourceVM: 12
    at org.apache.jasper.JspC.setCompilerSourceVM(JspC.java:724)
    at org.netbeans.modules.web.project.ant.JspC.main(JspC.java:80)
    at org.netbeans.modules.web.project.ant.JspCSingle.main(JspCSingle.java:119)
F:\Code\Netbean project\Smartphone Shop\nbproject\build-impl.xml:936: Java returned: 1
BUILD FAILED (total time: 0 seconds)
Run Code Online (Sandbox Code Playgroud)

如何修复这个错误?我使用 Netbeans 11.0 和 Tomcat 9.0。

小智 5

打开:

[YOUR PROJECT DIR]/nbproject/build-impl.xml
Run Code Online (Sandbox Code Playgroud)

并删除或注释掉这两行:

<arg value="-compilerSourceVM ${javac.source}"/>
<arg value="-compilerTargetVM ${javac.target}"/>
Run Code Online (Sandbox Code Playgroud)

就是这样。为我工作:)