?
Solved

call outside program

Posted on 2011-02-14
2
Medium Priority
?
479 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.
Suggested Courses

718 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