“Failed to load Premain-Class manifest attribute” while trying to get the size of an object using java agent

人走茶凉 提交于 2019-12-05 01:03:32

Make sure you have give full java path of the class containing the pre-main method. for example like this org.eclipse.anotherpckg.ObjectSizeFetcher. Secondly there must be a space before the name and carriage return at the end. for example

Manifest-Version: 1.0
Created-By: 1.5.0_18 (Sun Microsystems Inc.)
Premain-Class: org.eclipse.package.ObjectSizeFetcher

The last line is due to carriage return.

You should add in MANIFEST.MF:

Premain-Class: org.your.package.ObjectSizeFetcher + new line

insted

Premain-Class: ObjectSizeFetcher

It is an issue with the jar command itself. jar command must be used with cfm attributes, to include customized MANIFEST.MF, otherwise jar will create one file and insert its own contents which do not include the PreMain-Class attribute as we mention in customized manifest.mf file.

just run java size.jar ObjectSizeTest the problem is caused by java agent it has a tranformer class.

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