0

I have a Java Project that carries out Mechanical Turk HIT Tasks and I would like to use this within an Android app. I tried to write the MTurk functions within my android app, but I couldn't get it to work due to some errors related to the sdk jars. In short I have an Android App Project and a java Project. is there any way I can use the java project within my android project ?

Thomas
  • 43,637
  • 12
  • 109
  • 140
Nick Chris
  • 281
  • 2
  • 7
  • 17

1 Answers1

3
  1. You can export your java project as a jar, and add to other projects I think. (project-> right click -> export -> java -> jar files in eclipse). Add this jar files to lib folder in android project.
  2. If your java project doesn't have other dependancies, you can copy the source, with the full package, into your android project and reference it. It worked sometimes for me and sometimes doesn't. I think it is because the java project uses packages that is not present in android.
  3. Another way, but I never tried it. Right click your android project, choose Build path -> Configure Build path. In the resultant dialog, select Projects tab and click Add. Now select the project you want to link and click OK.

This question may not give a direct answer, but might help.

Community
  • 1
  • 1
Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167
  • So I've added the jar file. How do I use methods within that jar file ? – Nick Chris Dec 04 '12 at 05:54
  • I'm sorry but I'm a bit confused. In my java Project I have class called MTurkClass and I exported my java project into a jar called turk.jar . So how do I access the methods in the class MTurkClass ? – Nick Chris Dec 04 '12 at 05:58
  • First put the turk.jar into libs folder in your android project. If there is no folder named libs, create it and add. Make sure to reload your project in eclipse (project -> right click -> Refresh) after adding folder and jar. – Krishnabhadra Dec 04 '12 at 06:00
  • Then in your android project, import MTurkClass with the full java package name. Remember not the package name of your android project, but the package name of original java project. And then you can use that class, if everything goes right – Krishnabhadra Dec 04 '12 at 06:01
  • I've already added the jar file to the build path. The question now is how do i use the methods within that jar ? I tried import turk.MTurkClass, but that gives me a comoiler error – Nick Chris Dec 04 '12 at 06:02
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/20550/discussion-between-krishnabhadra-and-nick-chris) – Krishnabhadra Dec 04 '12 at 06:02
  • Hello click the link above and come into chat – Krishnabhadra Dec 04 '12 at 06:04