score:36

Accepted answer

You don't have to create any library, if you use the same workspace.

Option 1: Just use the source

In the properties of the project which has the dependencies you can add another source-folder:

Properties > Java Build Path > Tab: Source > Add Folder...

In the Project Tab you can "add" the whole project to the other project, too. There are many ways to achieve your goal.

Option 2: Create and add the library to the Build-Path

Adding an existing Jar (your own library):

If it is in the workspace:

Properties > Java Build Path > Tab: Libraries > Add JARs...

If it is somewhere on the drive:

Properties > Java Build Path > Tab: Libraries > Add External JARs...

Exporting a source folder as a library:

Context Menu of Source Folder > Export > Jar File

There are two types: Executable Jars and "normal" Jars. You don't need an executable Jar.

score:7

A Java library is basically a set of JAR files. So what you can do is generate a JAR based on your source code and add it as a external JAR to the Java build path of your Android and non-Android projects.


Related Query

More Query from same tag