Author Message
Athron
Joined: Nov 4, 2013
Messages: 40
Offline
Hi Guys,

Do you have a sample code in java that will run/executes a jar file within a servlet? Could you give an example.

Thank you in advance.
Athron
Joined: Nov 4, 2013
Messages: 40
Offline
By the way it is a customize jar file.
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
Assuming the jar is in the proper location (WEB-INF/lib or <tomcat_home>/lib) you can use

String className = "a.b.c.MyClass";
Class.forName(className).newInstance().

Not sure what you mean by "execute". The above is more for dynamically loading a class not known at compile time.
Go to:   
Mobile view