Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

call outside program

Posted on 2011-02-14
2
Medium Priority
?
480 Views
Last Modified: 2012-06-21
How to call a outside program.

I had a executable jar file... which upon calling executes a program
I want to execute that jar file from my struts java action class...

is it possible to call an outside jar file...

i heard shell api in java is used for calling such outside programs...

how to use that shell api.. can anyone provide me an example...

0
Comment
Question by:shragi
  • 2
2 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 total points
ID: 34888386
I hope this could be useful:
http://www.java-forums.org/advanced-java/26395-calling-jar-file-within-java-application.html

You can try to call main method of your starting class directly
from your code as you call any other method, if you ensure that your jar is in the classpath

You can also use Runtime.getRuntime().exec("java -jar ...") command like when starting anyothe  executable command ;
make sure that java  is in the PATH and you can provide -classpath in the argument line
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 2000 total points
ID: 34888479

In Java 6 you can also probably use Desktop command:
http://stackoverflow.com/questions/4989749/launching-external-programs-with-java

This is anew way though - never tried it myself, don't know if it works on all sysytems and if it is suitable
for server environment
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question