javajvmjconsole

JConsole Throws Exceptions When Launching


I got below error in a dialog when launching JConsole. If I close the dialog and click connection -> New Connection, I get the same error.

Currently, I am using Java11. Below are the path that I got when running where java and where jconsole:

C:\Program Files\Amazon Corretto\jdk11.0.20_8\bin\jconsole.exe

C:\Program Files\Amazon Corretto\jdk11.0.20_8\bin\java.exe

According to ChatGpt, I should have this folder C:\Users\myname\AppData\Local\Temp\hsperfdata_myname, However I didn't have it. I tried to create it but it doesn't resolve the problem.

Thanks for your helps and pointers. Cheers.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.protocol.local.LocalVmManager.activeVms(LocalVmManager.java:150)
    at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostProvider.activeVms(MonitoredHostProvider.java:150)
    at jdk.jconsole/sun.tools.jconsole.LocalVirtualMachine.getMonitoredVMs(LocalVirtualMachine.java:132)
    at jdk.jconsole/sun.tools.jconsole.LocalVirtualMachine.getAllVirtualMachines(LocalVirtualMachine.java:122)
    at jdk.jconsole/sun.tools.jconsole.ConnectDialog$ManagedVmTableModel.refresh(ConnectDialog.java:697)
    at jdk.jconsole/sun.tools.jconsole.ConnectDialog$ManagedVmTableModel.<init>(ConnectDialog.java:687)
    at jdk.jconsole/sun.tools.jconsole.ConnectDialog.<init>(ConnectDialog.java:121)
    at jdk.jconsole/sun.tools.jconsole.JConsole.showConnectDialog(JConsole.java:616)
    at jdk.jconsole/sun.tools.jconsole.JConsole$6.run(JConsole.java:829)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Solution

  • The root causes of it is Jconsole couldn't find the path to Temp folder correctly. That's why hsperfdata_myname wasn't created when launching Jconsole.

    What you can do is running below commands to figure out the Temp path.

    echo %TEMP% 
    echo %TMP%
    

    They both should point to the same location. e.g: C:\Users\myname\AppData\Local\Temp

    If not, fix them by searching Edit the system environment variables on your Windows search.