Reputation: 31
to get current process pid, my project used library sun.jvmstat.monitor.MonitoredHost in STS4. However, STS4 couldn't link this library and I couldn't compile my spring boot project.
import sun.jvmstat.monitor.MonitoredHost;
import sun.jvmstat.monitor.MonitoredVm;
import sun.jvmstat.monitor.MonitoredVmUtil;
import sun.jvmstat.monitor.VmIdentifier;
public class MonitorTest {
public static void main(String[] args) {
}
}
That's all the code I have.
Error :
The type sun.jvmstat.monitor.MonitoredHost is not accessible
The type sun.jvmstat.monitor.MonitoredVm is not accessible
The type sun.jvmstat.monitor.MonitoredVmUtil is not accessible
The type sun.jvmstat.monitor.VmIdentifier is not accessible
used openJDK version is :
java -version
openjdk 11.0.1 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
Upvotes: 1
Views: 3913
Reputation: 4596
To Solve in Eclipse/STS3-4 version Thanks to this post, I am able to do changes in eclipse and STS both.
jdk.internal.jvmstat
sun.jvmstat.monitor
modify a file .idea/compiler.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="demo.main" options="--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED" />
</option>
</component>
</project>
or
Auto-resolve will prompt for above file modification as
This will solve the issue with idea ide.
maven
or gradle
thenjavac --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --class-path $dependencies -d $targetFolder $sourceFiles
Upvotes: 2