Create Java runtime image on one platform for another using Jlink

The include directory is for header files, such as jni.h, that are needed when compiling C/C++ code that uses JNI and other native interfaces. It’s nothing to do with jlink. The jlink tool can create a run-time image for another platform (cross targeting). You need to download two JDKs to do this. One for the … Read more

How to apply Filtering on groupBy in java streams

You can make use of the Collectors.filtering API introduced since Java-9 for this: Map<String, List<Employee>> output = list.stream() .collect(Collectors.groupingBy(Employee::getDepartment, Collectors.filtering(e -> e.getSalary() > 2000, Collectors.toList()))); Important from the API note : The filtering() collectors are most useful when used in a multi-level reduction, such as downstream of a groupingBy or partitioningBy. A filtering collector differs … Read more

Generics behavior differs in JDK 8 and 9

After some research I believe we can rule this out as a Junit or hamcrest issue. Indeed, this seems to be a JDK bug. The following code will not compile in JDK > 8: AnyOf<Iterable<? super String>> matcher = CoreMatchers.anyOf( CoreMatchers.hasItem(“d”), CoreMatchers.hasItem(“e”), CoreMatchers.hasItem(“f”)); Error:(23, 63) java: incompatible types: inference variable T has incompatible bounds equality … Read more

Properly implementing Java modules in a Maven build with inter-module test dependencies

Based on your demo project, I was able to duplicate your error. That said, here are the revised changes I made, after my first failed attempt, to be able to build the project: I added the maven-compiler-plugin version 3.8.0 to all the modules. You need a version of 3.7 or higher to compile modules with … Read more

In JShell, how to import classpath from a Maven project

You can use the jshell-maven-plugin: mvn com.github.johnpoth:jshell-maven-plugin:1.3:run which will fire up a JShell session with your project’s runtime path. If you want to include your test dependencies just add -DtestClasspath to the command. NOTE: the plugin expects the project to be built already. If not, invoke the appropriate Maven build phase before the plugin e.g: … Read more

Is it possible to mix –class-path and –module-path in javac (JDK 9)?

You can use class path and module path in parallel, but there are a few details to consider. Dependency Module Path ~> Class Path Explicit modules (JARs with a module descriptor on the module path) can not read the unnamed module (JARs on the class path) – that was done on purpose to prevent modular … Read more

Loading classes and resources post Java 9

First, to set the record straight, I neither said nor wrote the text quoted above. I’d never have put it that way. That’s just sloppy reporting on the part of the publications involved. The most important thing to understand about class loading and resource lookup in Java 9 is that, at a fundamental level, they … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)