1

I created my own jar file using eclipse. Now i am trying to make an android JAR file and then will use the same JAR file in others android apps.

Now though, my application is complete and make a jar file, but how i will use it for other Android Apps?

Jeff Yates
  • 61,417
  • 20
  • 137
  • 189
naeemgik
  • 2,232
  • 4
  • 25
  • 47
  • See http://stackoverflow.com/questions/1334802/how-can-i-use-external-jars-in-an-android-project – Sandeep Pathak Jul 28 '11 at 10:55
  • thank u for your reference url but i have done it already what i want to do is how to use my this own created jar file in other android apps after importing successfully. how to call my this jar file classes and methods and execute them successfully any idea??? – naeemgik Jul 28 '11 at 12:51

2 Answers2

0

You should be able to access any publicly exposed methods from your .jar by importing the .jar into your project, then adding

import myjar.myclass;

You can then reference any methods from the class you import.

Hope this helps!

Codeman
  • 12,157
  • 10
  • 53
  • 91
  • thanx for your reply, whats the role of Class-Path and Main-Class in manifest.txt of Jar file?? is it some thing of importance??? – naeemgik Jul 28 '11 at 14:27
  • I would not touch those unless you know exactly what you are doing with them, you can mess up your project configuration quite easily. It is better to let the IDE handle them. The class path is just the reference to external classes so you can actually access them, whereas the main class is the "main" class of the file, i.e. where code begin executing when the program executes. – Codeman Jul 28 '11 at 14:34
  • In android apps there is no main() now should Main-Class: MyClass will contain main() method or no need of main(), just onCreate() method is enough – naeemgik Jul 29 '11 at 04:37
  • The main activity you created is effectively your "main" class. Like I said, you shouldn't need to mess with it. Import your .jar into the project and reference it with imports. – Codeman Jul 29 '11 at 13:30
0
  1. Add the jar to you build path
    • Right click project
    • Click "Properties" -> "Java Build Path" -> "Libraries"
    • Click "Add External Jar"
  2. Import classes like normal

    import com.my.package.here.MyClass;
    
Austin Hanson
  • 21,820
  • 6
  • 35
  • 41