tags:

views:

63

answers:

2

I've written an Android app wich various abstract classes that perform useful functions. These functions could be leveraged in other apps.

I want to share a class module with another programmer, but I don't want to share the source code. I would like to share a .class file but I'm not sure how to do the following:

  • Compile an Android .java file into .class
  • What does the receiver of the .class file have to do to use that .class in their project? (using Eclipse environment)

Thank you very much

+2  A: 

You'll probably want to create a JAR. There's a lot of information about how to do this in Eclipse. See this how-to for a start. Basically, you just go to File->Export->Jar File. For the import side, see How to Add JARs to Project Build Paths in Eclipse (Java).

However, you should realize that it's quite easy to decompile Java classes.

Matthew Flaschen
Understood, thanks for the warning. I suppose I should just release open source anyways. At least now I understand my options!
Brad Hein
I gave you +1 and accepted the other answer because you guys both posted at the same time and I had to pick one :) Great answer though - thanks again!
Brad Hein
+2  A: 

You would share it using a .jar file. Eclipse has a wizard for exporting your classes as a jar file.

To import it into your Android project in Eclipse: http://developer.android.com/intl/zh-CN/guide/appendix/faq/commontasks.html#addexternallibrary

mbaird