• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

call java (main) program from JSP

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a java program, which is supposed to run as a batch. Would like to know how to invoke this batch program from the JSP page.
Thanks in advance.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You use the java.lang.Runtime.getRuntime().exec() call to execute a process on the server. Keep in mind that the JSP simply becomes a servlet that executes on the <b>server</b> not the client. I have had good luck executing a shell script on Unix systems or batch (.bat or .cmd) files in Windows.
However, if you are executing Java, first look into using the exposed Java API (if there is one) of whatever you are doing and running in the same VM with the following warning
<b>Do not call the main method of some Java class from another Java class as often the main method terminates by calling System.exit() which will kill the JVM.</b>
 
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic