Creating a jar file in Android
I want to create a jar file with my own classes.
Can anyone give me sample code for creating a simple jar file 开发者_JAVA百科in Android?
If you want to do it via Eclipse, it's easy.
Go to File:->Export
. Then choose jar file in jar folder than simply choose proper app and than settings for it so you can export it easily.
It's very easy.
Do what Make a folder on to the desktop say MyFolder.
In that folder place the main package of your .class files or directly the class file if they belong to no package.
Say my.main.package is the package that have your classes.
Now the folder MyFolder has one folder by name my in it. Now open the console window and take it to MyFolder Location.
Like this C:\Documents and settings\Rohit\Desktop\MyFolder>
Write command like below:
C:\Documents and settings\Rohit\Desktop\MyFolder>jar -cvf MyJar.jar my
it will create a jar of your classes that you can import through Eclipse.
and if say you want to make a jar file that will have more then one main package along some class files then write the following command:
C:\Documents and settings\Rohit\Desktop\MyFolder>jar -cvf MyJar.jar my my2 *.class
Check this Creating a JAR File
You will get the .class
file in the bin folder
精彩评论