Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;

import java.lang.management.ManagementFactory;
import java.util.ArrayList;

public class Main {
    public static MBeanServer findMBeanServer() {
        ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
        if (servers == null || servers.isEmpty()) {
            return ManagementFactory.getPlatformMBeanServer();
        }

        return servers.get(0);
    }
}