Issue
I Have two applications.One is Standalone application.Another one is web Application (Servlet App). Here I want to Call Java Application From Servlet Application.So can You Guys Suggest Me or Can i have one app for this one.So that i will implement in my application. In this Application I have created Jar file of Stand alone Application After that What to do ?
Solution
First, you should make your command line application classes available in your web applcaction environment. To achieve this you should either:
- package all in one jar
- put classes of stand alone application under
WEB-INF/classes
in youwar
- put jar that contains your stand alone application under
WEB-INF/lib
in youwar
Stand alone application starts from main()
method. You can just call this method from your servlet and pass parameters, for example: MyApp.main("hello", "stand alone application")
.
Since you are the author of both applications and are familiar with the internal design of the stand alone application you could (and probably should) call internal layer directly without using main()
. For example if you main method starts with new MyApp().start()
perform the same call from your servlet.
Answered By - AlexR