Java 9 javac有一个新的标志--release:
> javac --help
...
--release <release>
Compile for a specific VM version. Supported targets: 6, 7, 8, 9
Run Code Online (Sandbox Code Playgroud)
它-source与-target旗帜有什么不同?它只是一个捷径-source X -target X吗?
我收到以下错误,但我可以在 rt.jar 中找到该包。我可以从项目结构中看到正在使用的 JDK。我不确定缺少什么。
Error:(6, -1) Play 2 Compiler:
C:\user\projects\portal\app\com\example\security\cert\X509Cert.java:6: package sun.security.pkcs10 does not exist
import sun.security.pkcs10.*;
C:\user\projects\portal\app\com\v\security\cert\GenerateCSR.java:75: cannot find symbol
Run Code Online (Sandbox Code Playgroud) 考虑maven项目中的以下代码:
import org.w3c.dom.css.CSSStyleDeclaration;
public class Test {
public static void main(String[] args) {
CSSStyleDeclaration styleDeclaration = null;
}
}
Run Code Online (Sandbox Code Playgroud)
哪里pom.xml包含maven-compiler-plugin插件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.serce.jdk10mvntest</groupId>
<artifactId>jdk10mvntest</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
可以使用maven编译该项目,没有错误.但是,当它使用带有JDK10 SDK的IntelliJ编译时,会Error:(1, 27) java: package org.w3c.dom.css does not exist出错.如果源更改为<source>10</source>错误消失.我希望问题可能与拼图相关,但我无法使用--add-modules ...因为javac错误option --add-modules not allowed with target 1.8.
是否有任何变通方法允许我使用IntelliJ与JDK10 SDK以及 …
java compilation intellij-idea java-platform-module-system java-10
当使用ant, 调用sun.awt.AppContext工作时,但是使用 AdaptOpenJDK11 使用 IntelliJ 编译的相同代码失败。
sun.awt.AppContext使用Oracle JDK8与 IntelliJ 配合使用sun.awt.AppContext采用AdoptOpenJDK11不适用于IntelliJ尽管 Sun/Oracle 已经警告过一段时间要避免使用这些sun.*包,但Java中的某些功能(错误?)仍然需要它们,而且很奇怪,命令行似乎很高兴。
示例代码:
package test;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import sun.awt.AppContext;
public class Main {
public static void main(String[] args) {
//Update printer list in CUPS immediately
AppContext.getAppContext().put(PrintServiceLookup.class.getDeclaredClasses()[0], null);
PrintService[] printers = PrintServiceLookup.lookupPrintServices(null, null);
for (PrintService p : printers) {
System.out.println(p.getName());
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何配置 IntelliJ 使其表现得像ant并允许访问sun.awt.* …
java ×4
adoptopenjdk ×1
compilation ×1
java-10 ×1
java-11 ×1
java-9 ×1
java-platform-module-system ×1
javac ×1
openjdk-11 ×1
sbt ×1