包 com.sun.jdmk.comm 不存在

package com.sun.jdmk.comm does not exist

我找到了使用 jmx 的例子:

import javax.management.*;
import java.lang.management.*;
import com.sun.jdmk.comm.HtmlAdaptorServer;

public class SimpleAgent
{
    private MBeanServer mbs = null;

    public SimpleAgent()
    {
        // Получить экземпляр MBeanServer
        mbs = ManagementFactory.getPlatformMBeanServer();
        HtmlAdaptorServer adapter = new HtmlAdaptorServer();

        // Создаем наш MBean
        Hello helloBean = new Hello();
        ObjectName adapterName = null;
        ObjectName helloName = null;

        try {
            // И регистрируем его на платформе MBeanServer
            helloName = new ObjectName("SimpleAgent:name=hellothere");
            mbs.registerMBean(helloBean, helloName);

            // Теперь мы регистрируем коннектор, который
            // будет доступен по HTTP-протоколу
            adapterName = new ObjectName("SimpleAgent:name=htmladapter,port=8000");
            adapter.setPort(8000);
            mbs.registerMBean(adapter, adapterName);
            adapter.start();

        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    // Это вспомогательный метод - он позволяет нашей программе
    // остановиться и ждать
    private static void waitForEnterPressed()
    {
        try {
            System.out.println("Press  to continue...");
            System.in.read();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String argv[])
    {
        SimpleAgent agent = new SimpleAgent();
        System.out.println("SimpleAgent is running...");
        SimpleAgent.waitForEnterPressed();
    }
}

但是在代码编译后我看到以下消息:

java: package com.sun.jdmk.comm does not exist

java: cannot find symbol
  symbol:   class HtmlAdaptorServer
  location: class com.journaldev.jmx.SystemConfigManagement

java: cannot find symbol
  symbol:   class HtmlAdaptorServer
  location: class com.journaldev.jmx.SystemConfigManagement

我用jdk1.8

我应该使用外部库来纠正提到的错误吗?

在构建路径中添加 jmxtools.jar

或添加以下 Maven 依赖项:

<dependency>
    <groupId>com.sun.jdmk</groupId>
    <artifactId>jmxtools</artifactId>
    <version>1.2.1</version>
</dependency>

将此依赖项添加到您的 pom.xml

<!-- https://mvnrepository.com/artifact/com.betfair.net.java.opendmk/core -->
<dependency>
    <groupId>com.betfair.net.java.opendmk</groupId>
    <artifactId>core</artifactId>
    <version>1.0-b02</version>
</dependency>