获取当前项目名称和当前项目进程的工具类

public class SystemDemo {
    public static void main(String[] args) {
        /**
         * 获取项目名称
         */
        System.out.println("项目名称:" + System.getProperty("user.dir"));

        RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();

        Integer processNo = Integer.valueOf(runtimeMXBean.getName().split("@")[0])
                .intValue();
        System.out.println("进程Id:" + processNo);

        System.out.println("进程启动时间:" + new Date(runtimeMXBean.getStartTime()));
    }
}

 

posted @ 2021-12-02 16:46  WK_BlogYard  阅读(94)  评论(0编辑  收藏  举报