Solved

call outside program

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

710 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