Solved

call outside program

Posted on 2011-02-14
2
465 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 500 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 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
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 video teaches viewers about errors in exception handling.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now