Kevin
Kevin

Reputation:

How to invoke a method at runtime from a jar file

I have multiple jar files at a specific location .Based on some calculation, I need to load different jar files and invoke a certain method inside the jar. The jar file contains methods that act as a client to web services. When I invoke the method using reflection, it throws an error Wrapper class not found. Have you run APT to generate them?

Upvotes: 2

Views: 3512

Answers (3)

toolkit
toolkit

Reputation: 50237

Just checking you aren't using -jar option at all? This is mutually exclusive of -classpath. See here for more explanation.

Upvotes: 0

Nat
Nat

Reputation: 9951

It sounds like the classes that you are loadiing from the JAR use other classes that are not on the classpath. You can add the libraries they depend on to the system classpath of your application or list them in the Class-Path entry in the manifest files of the JARs you are loading.

Upvotes: 1

Ronald Wildenberg
Ronald Wildenberg

Reputation: 32094

Check out this question for a possible solution.

I'm not sure why you would get such an error when you attempt to call a method via reflection but a little googling came up with this forum post (among others).

Upvotes: 0

Related Questions