判断 Java 程序的运行方式, file(在IDE中运行) 或 jar(以jar包方式运行)

博文目录

文章目录


java判断是ide还是jar包运行

System.out.println(Main.class.getResource("").getProtocol());
if (Main.class.getResource("").getProtocol().equals("jar")) {
    
    
	// 以 jar 的方式运行
}

猜你喜欢

转载自blog.csdn.net/mrathena/article/details/124413570
今日推荐