2

I add and remove some classes during editing a Java library project.

E.g., I added the two classes.

  1. Dummy1.java
  2. Dummy2.java

Then I right-click the source folder (src where all the packages are) of my library project and export it to a JAR. I check the 'Export Java source files and resources' checkbox when I export the library.

Then I right-click a client project which uses the library and add the JAR like this.

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

Dummy1 and Dummy2 can be used in the project.

After that I add Dummy3.java to the library project and modify Dummy2, Then I export the library to the JAR again.

Now I can use Dummy1 and Dummy2 (except my last modifications) in the client project. Dummy3 will be accessible after removing and re-adding the JAR to the client project through Properties. If I have one or two clients, it'll be OK to add the JAR every time. But if five or seven clients use it, I'll take me a lot of time to remove and re-add after adding a variable to a class of the library project.

Update #1.

An Android project and a GWT project use the library.

Update #2 (it works for the Android project).

I have successfully added a JAR to the Android project.

  1. I edited a class in the library project.
  2. I exported the library to a JAR.
  3. I manually copied the JAR to the Android project's directory.
  4. I can use the last changes of my library in the Android project.

The guides were helpful.

  1. http://www.youtube.com/watch?v=eY_uqi_qIz0
  2. https://stackoverflow.com/a/1337933/1065835
Community
  • 1
  • 1
Maksim Dmitriev
  • 5,985
  • 12
  • 73
  • 138
  • 1
    Have you considered using Maven, or some other similar tool? – Adam Arold Aug 13 '13 at 11:02
  • @AdamArold, not yet. If it can solve the question, I'll learn a tool. – Maksim Dmitriev Aug 13 '13 at 11:05
  • 4
    If one project depends on another one and they are in the same workspace, you don't have to use a .jar, just add the project under Properties > Java Build Path > Projects – Guillaume Aug 13 '13 at 11:10
  • @Guillaume, unfortunately, it doesn't work for my Android project. I ran into `NoClassDefFoundError`. After reading [this](http://stackoverflow.com/a/8001414/1065835) and [this](http://tools.android.com/recent/dealingwithdependenciesinandroidprojects) I copied the JAR to `libs` folder and made it work. – Maksim Dmitriev Aug 13 '13 at 13:40
  • @Red Planet this seems to be Android specific, you should rewrite your question and make it clear that this is an android project. – Guillaume Aug 13 '13 at 14:25
  • @Guillaume, I have got the Android project and a GWT project which use the same classes. And OK, I'll update the question. – Maksim Dmitriev Aug 14 '13 at 05:07

0 Answers0