Is it possible to convert .class
file to .jar
file using c++ code?
(i.e can we write a code in 开发者_运维知识库c++ that when executed converts given .class file to .jar file)
If yes,how can i do that?
A .jar file is just ZIP archive containing .class files and possibly a manifest file. (The most important part of the manifest file is the name of the class to run with java -jar
.) You can generate a .jar file quite easily in C++ from the .class file, by using a library which can generate ZIP archive files.
If you don't care about the size savings because of compression in the ZIP file, you can easily create an uncompressed ZIP file, even without using a library. The ZIP format is documented e.g. here: http://en.wikipedia.org/wiki/ZIP_%28file_format%29
精彩评论