create a folder (like lib) inside your project, copy your jar to that folder. now go to configure build path from right click on project, there in build path select

'add jar' browse to the folder you created and pick the jar.


copying the .jar file into the android project's folder isn't always possible.
especially if it's an output of another project in your workspace, and it keeps getting updated.

to solve this you'll have to add the jar as a linked file to your project, instead of importing it (which will copy it locally).

in the ui choose:

project -> import -> file system -> yourjar.jar -> (options area) advanced -> create link in workspace.

the link is save in the .project file:


parent-5-project_loc means relative to the project file, 5 directories up (../../../../../).

then add it to the libraries:
project -> properties -> java build path -> libraries -> add jar -> yourjar.jar

in the same window choose the order and export tab and mark your jar so it will be added to the apk.


android's java api does not support javax.naming.* and many other javax.* stuff. you need to include the dependencies as separate jars.


if using android studio, do the following (i've copied and modified @vinayak bs answer):

  1. select the project view in the project sideview (instead of packages or android)
  2. create a folder called libs in your project's root folder
  3. copy your jar files to the libs folder
  4. the sideview will be updated and the jar files will show up in your project
  5. now right click on each jar file you want to import and then select "add as library...", which will include it in your project
  6. after that, all you need to do is reference the new classes in your code, eg. import javax.mail.*


in android studio if using gradle

add this to build.gradle

compile filetree(dir: 'libs', include: ['*.jar'])

and add the jar file to libs folder


if you are using gradle build system, follow these steps:

  1. put jar files inside respective libs folder of your android app. you will generally find it at project > app > libs. if libs folder is missing, create one.

  2. add this to your build.gradle file your app. (not to your project's build.gradle)

    dependencies {
        compile filetree(dir: 'libs', include: '*.jar')
        // other dependencies

    this will include all your jar files available in libs folder.

if don't want to include all jar files, then you can add it individually.

compile filetree(dir: 'libs', include: 'file.jar')


goto current project

rightclick->properties->java build path->add jar files into libraries -> click ok

then it is added into the referenced libraries file in your current project .


turns out i have not looked good enough at my stack trace, the problem is not that the external jar is not included.

the problem is that android platform is missing javax.naming.* and many other packages that the external jar has dependencies too.

adding external jar files, and setting order and export in eclipse works as expected with android projects.


i'm currently using sdk 20.0.3 and none of the previous solutions worked for me.

the reason that hessdroid works where hess failed is because the two jar files contain java that is compiled for different virtual machines. the byte code created by the java compiler is not guaranteed to run on the dalvik virtual machine. the byte code created by the android compiler is not guaranteed to run on the java virtual machine.

in my case i had access to the source code and was able to create an android jar file for it using the method that i described here:


i know the op ends his question with reference to the eclipse plugin, but i arrived here with a search that didn't specify eclipse. so here goes for android studio:

  1. add jar file to libs directory (such as copy/paste)
  2. right-click on jar file and select "add as library..."
  3. click "ok" on next dialog or renamed if you choose to.

that's it!


yes, you can use it. here is how:

  1. your project -> right click -> import -> file system -> yourjar.jar
  2. your project -> right click -> properties -> java build path -> libraries -> add jar -> yourjar.jar

this video might be useful in case you are having some issues.


for eclipse

a good way to add external jars to your android project or any java project is:

  1. create a folder called libs in your project's root folder
  2. copy your jar files to the libs folder
  3. now right click on the jar file and then select build path > add to build path, which will create a folder called 'referenced libraries' within your project

    by doing this, you will not lose your libraries that are being referenced on your hard drive whenever you transfer your project to another computer.

for android studio

  1. if you are in android view in project explorer, change it to project view as below

missing image

  1. right click the desired module where you would like to add the external library, then select new > directroy and name it as 'libs'
  2. now copy the blah_blah.jar into the 'libs' folder
  3. right click the blah_blah.jar, then select 'add as library..'. this will automatically add and entry in build.gradle as compile files('libs/blah_blah.jar') and sync the gradle. and you are done

please note : if you are using 3rd party libraries then it is better to use transitive dependencies where gradle script automatically downloads the jar and the dependency jar when gradle script run.

ex : compile ''

read more about gradle dependency mangement

Related Query

More Query from same tag