java-9

Java 9 HttpClient hangs

断了今生、忘了曾经 提交于 2021-02-07 12:30:15
问题 I'm experimenting with HTTP/2 client from jdk 9-ea+171 . The code is taken from this example: HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(new URI("https://www.google.com/")) .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandler.asString()); But the client hangs on the last line forever. Please advice how to fix it? Debugging shows it infinitely waits in method waitUntilPrefaceSent() . 回答1: This is a bug

HiDPI support in Java Swing for multiple look and feels

蓝咒 提交于 2021-02-06 12:59:08
问题 I'm looking to add Hi-DPI support to some Swing applications, but I have failed to find a solution sufficient to my needs. I need to support multiple look & feels, so the situation seems rather more complex than other posts I've found (which tend to suggest "adapt your UI sizes to match your font size"). Some experimentation has found the UIManager contains many metrics that can be tweaked to get you off to a good start in making an application Hi-DPI friendly. (The UIManager-Defaults utility

List modules in jar file

烈酒焚心 提交于 2021-02-06 09:58:14
问题 I've created what I'm pretty sure is a modular jar file. But if possible, I'd like to double check. Given a jar file, is there a way to determine what modules the compiler would find within it? 回答1: The alternative is to use the jar --describe-module ( -d for short), e.g.: jar --file=myjar.jar --describe-module 回答2: You can list the modules within the jar using the following java tool command:- java -p yourModular.jar --list-modules Edit : You shall preferably make use of the jar command lin

java.util.Objects vs Optional which is preferable?

和自甴很熟 提交于 2021-02-06 09:55:07
问题 The java.util.Objects class was extended with a number of new methods Objects#requireNonNullElse respectively Objects#requireNonNullElseGet() in Java-9 . Both will return the first argument if it is non-null and otherwise returns the non-null second argument or the non-null value of supplier.get() jshell> String nullStr = null; nullStr ==> null jshell> Objects.requireNonNullElse(nullStr,"lorem ipsum"); $13 ==> "lorem ipsum" jshell> Objects.requireNonNullElseGet(nullStr,() -> "lorem ipsum");

How to use a Windows filename with a colon with Java 9 unified logging?

末鹿安然 提交于 2021-02-04 18:53:28
问题 % java11 -Xlog:gc*:file=c:\max.txt -version [0.002s][error][logging] Invalid decorator '\max.txt'. Invalid -Xlog option '-Xlog:gc*:file=c:\max.txt', see error log for details. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. Apparently with Java 9 (and later) unified logging a colon is used as a separator between fields in the -Xlog arguments. So, how do I specify a Windows pathname that has a colon in it? Is there an escape of some

How to use a Windows filename with a colon with Java 9 unified logging?

倾然丶 夕夏残阳落幕 提交于 2021-02-04 18:53:24
问题 % java11 -Xlog:gc*:file=c:\max.txt -version [0.002s][error][logging] Invalid decorator '\max.txt'. Invalid -Xlog option '-Xlog:gc*:file=c:\max.txt', see error log for details. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. Apparently with Java 9 (and later) unified logging a colon is used as a separator between fields in the -Xlog arguments. So, how do I specify a Windows pathname that has a colon in it? Is there an escape of some

Java 9: Exporting packages to unnamed modules fail

亡梦爱人 提交于 2021-02-04 14:42:47
问题 I am trying to build an open-source project against Java 9. There are some files which I need to access using reflection but I cannot because the packages are not exported by their modules. I export the packages to unnamed modules by using the arguments --add-exports . I have added the following arguments to environment variable _JAVA_OPTIONS : -Dsun.reflect.debugModuleAccessChecks=true --add-exports=javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED --add-exports=javafx.controls/com

Java 9: Exporting packages to unnamed modules fail

♀尐吖头ヾ 提交于 2021-02-04 14:41:40
问题 I am trying to build an open-source project against Java 9. There are some files which I need to access using reflection but I cannot because the packages are not exported by their modules. I export the packages to unnamed modules by using the arguments --add-exports . I have added the following arguments to environment variable _JAVA_OPTIONS : -Dsun.reflect.debugModuleAccessChecks=true --add-exports=javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED --add-exports=javafx.controls/com

Spring Boot 2 + Java 9 + Querydsl

一个人想着一个人 提交于 2021-01-27 14:54:49
问题 I have successfully updated my application (Spring Boot + Java + Maven) to Spring Boot 2. Now I'm trying to update to Java 9. According to Nicolas Fränkel's blog post (Migrating a Spring Boot application to Java 9 - Compatibility) I accomplished to update to Java 9 without using a module-info file. But when I create such a file, the apt-maven-plugin gets stucked on creating the Q-types. Has anyone successfully completed using Java 9 + Maven + Querydsl? My Maven configuration for the apt-maven

Spring Boot 2 + Java 9 + Querydsl

戏子无情 提交于 2021-01-27 14:34:46
问题 I have successfully updated my application (Spring Boot + Java + Maven) to Spring Boot 2. Now I'm trying to update to Java 9. According to Nicolas Fränkel's blog post (Migrating a Spring Boot application to Java 9 - Compatibility) I accomplished to update to Java 9 without using a module-info file. But when I create such a file, the apt-maven-plugin gets stucked on creating the Q-types. Has anyone successfully completed using Java 9 + Maven + Querydsl? My Maven configuration for the apt-maven