0

I have a standalone.jar which will be packaged inside super.war. Stanalone.jar uses a function from super.war. My confusion is how can I call a method from super.war when I am developing a functionality inside a class in my war since both of them are different projects in eclipse?

To elaborate more:

Super.war has a class call Motors which has a method called getMotors. standalone.jar has a class called Customer which needs to call getMotors of super.war. Now, my question is how can I create an object and call a method of Motors class which is in war inside Customers class which is in jar.

Please help.

Thank you

Gendaful
  • 4,772
  • 10
  • 50
  • 73

2 Answers2

2

You need the project containing the Motors class to be on the build path of the standalone.jar project.

If you also need the standalone.jar project to be on the build path of the WAR project, then it seems you have a cyclic dependency between these projects which you should break; perhaps by putting the common classes in a 3rd project/jar.

matt b
  • 132,562
  • 64
  • 267
  • 334
  • Please see, this stanalone.jar is dependant on Motors class but war is not dependant on jar. Jar has a scheduler in it which runs independently and fetch the records. – Gendaful Oct 11 '12 at 15:34
  • then the Motors class needs to be in the JAR or in a dependency of the JAR. If you also need the Motors class in the WAR project, the best solution is to put it in a 3rd JAR that both projects can depend on. – matt b Oct 11 '12 at 15:35
  • 1
    @Gendaful What matt is saying is right. You can create a 3rd "commons.jar" (for example) that contains the intersection of the dependencies of both parties, so they can keep their independency. The WAR won't depend on `standalone.jar`, both the WAR and `standalone.jar` will depend on your `commons.jar` library. – Fritz Oct 11 '12 at 15:49
  • Thanks for the info. I understood it completely – Gendaful Oct 11 '12 at 16:27
1

You can't. By doing this, standalone.jar wouldn't be so standalone any more. :) You would probably create a circle-ref.

You'll have to find a way to use some common interface.

Fildor
  • 11,419
  • 4
  • 29
  • 57