Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting class file to jar file using c++

Tags:

java

c++

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?

like image 805
Suhail Gupta Avatar asked May 14 '11 13:05

Suhail Gupta


People also ask

How do I import a .class file into a jar?

Click the Libraries tab in this dialog, click Add External JARs for . jar files or Add Class Folder for . class files, navigate to the . jar file or to the folder containing .

How do I create a .JAR file?

Open the Jar File wizard In the Package Explorer select the items that you want to export. If you want to export all the classes and resources in the project just select the project. Click on the File menu and select Export. In the filter text box of the first page of the export wizard type in JAR.


1 Answers

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

like image 88
pts Avatar answered Oct 04 '22 05:10

pts