How to get java main class from jar file

限于喜欢 提交于 2019-12-08 19:47:30

问题


I have an executable jar and i want to know the name of java main class from this jar

My question are if there is a java cmd to get this from jar metadata ?


回答1:


You can use unix command : unzip -p XXX.jar META-INF/MANIFEST.MF

or you can use jar commad jar tf XXX.jar and see the content of MANIFEST.MF.




回答2:


Technically a jar file can contain more than one main class.

When java executes a jar file, it looks in the META-INF/MANIFEST.MF file inside the jar to find the entrypoint.

There is no direct command to get this information, but you can unpack the jar (it's just a zip file) and look into the manifest yourself.

More about the manifest: https://docs.oracle.com/javase/tutorial/deployment/jar/defman.html

More about application entrypoints: https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html



来源:https://stackoverflow.com/questions/38164604/how-to-get-java-main-class-from-jar-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!