Call other programs from Java
There is this command line program I want to wrap with a Java class in order to make it available so that it can be transparently called.
How can I call or execute external programs/commands from JAVA...
is not native code that I want to run...
Thank you
Runtime.getRuntime().exec("your command line")... you could read more about it in the API documentation.
Similar Messages
-
Error in calling 'C' Program from Java
Hi,
We developed a 'C' Program and during compilation, we got a couple of Incompatible Prototype warnings. Then we made a Jni call to 'C' program from Java Program. The program returned a "Unsatisfied Link Error - unreference Symbol not found" error.
Does Jni call fails owing to warnings by compiler?
We are using Sun Solaris 2.8.
Request your assistance as this a urgent issue.
Thanks
SriniDid you try running your C program through g++? It sounds like something is broken, but GCC often will allow you to compile anyways.
-Jason Thomas. -
Calling PERL program from JAVA
what is the most efficient way to call PERL scripts from JAVA class?
please help,
thank you,use of Webservices is the best answer which anyone can give you
Alright you might have to take help of XML-RPC(by hosting perl in a remote server) to call perl routines from java Class instances.
How you do that ?? please go ahead and try get more insight information from the below aritcle
http://www.javaworld.com/javaworld/jw-10-2004/jw-1011-xmlrpc.html
and if you are instrested in any other core solutions
http://www.perl.com/pub/a/2003/11/07/java.html
http://sunsite.ualberta.ca/Documentation/Misc/perl-5.6.1/jpl/docs/Tutorial.html
http://search.cpan.org/~patl/Inline-Java-0.52/Java/PerlInterpreter/PerlInterpreter.pod
http://www.perlmonks.org/index.pl?node_id=373839
the above links might intrest you.
Hope that might help :)
REGARDS,
RaHuL -
Calling external programs from Java?
Hi All,
Is there a way of calling external applications from Java without using Runtime.exec(). That method seems quite messy when you are dealing with streaming data from an input file to an output file. Basically what I'm asking is there a way to run a command the same way you would type it in a command shell?
ThanksLeWalrus wrote:
Ok, I've an external application that I want to be called inside a Java GUI. It has several input arguements, which the format looks something like:
programname inputfile > outputfile
Simple enough.
>
Works fine from a shell command line. From what I understand, this won't work using Runtime.exec() because that method will just start the application. Works fine from Runtime.exec(). Since you are'>' to write stdout to a file you need to us a shell to execute the command.
String[] command = {"sh", "-c","programname inputfile > outputfile"};
Process process = runtime.exec(command);
You need to read, digest and implement the recommendations given in http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .
File input and output from the application has to be taken care of programatically (java.io stuff). Fine if you've only one input and output. But if you have several input files and hundreds of output files, where does this leave you. It would be much easier if you could pass a string command to the shell directly as if you typed it in the command line yoursel! -
Hi,
we have written some code in c and we need to call those codes from an interface written in java. How do I do it ?
so far as i heard, there is something call java native interface...is that true...how do i call up the c programjava native interface...is that true...how do i call up the c program
JNI Tutorial
JNI Tutorial (ZIP)
(found by the Magic of Google: JNI Tutorial)
or Runtime.exec if you c program is a complete program. -
How to call other program in java
how do i write code to call a program, software in window envirenment?
such as opening Microsoft Excel files using Microsoft excel?
plz helppublic static void main(String[] args)
try
Runtime.getRuntime().exec("Book1.xls");
catch (IOException ed)
}i tried, but it not working , plz help -
Calling windows programs from Java
Hello,
I need to find how to call and pass parameters to windows programs. Specifically I need to call MS Sql server, there is call that I can do from command promt but I would like to give it some GUI interface and ease of use so I could pass some parameters to the program and execute it.
Thanks.Hi thanks for all replies !
Ok let me explain more about my problem.
I have a SQL server which runs on MS machine and there is thousands of stored procs that my be recreated once in a while from a directorys. So we have scripts which we have to manually update every time new stored proc is written and run against the server to update all of them at one batch.
Now I often have to browse to this directory from linux machine and I basically already written the Java program that gets all the files in the directory and passes them via JDBC to the server.
Thats where the problem starts, when you calling and passing sp to sql without any header seting the jdbc is fine but when you pass sp with such settings for instanse as "SET QUOTED_IDENTIFIER and SET ANSI_NULLS OFF" in the header of stored proc then SQL server complains and fires exceptions on me.
So this is my problem. -
Hi All,
I'm somwhat new to Java (coming from an AS400 background) and I'm stuck with what I think is a fairly simple problem. But I've been looking at this for so long, I'm probably missing something really simple and I hope someone can help me with this.
I've created a bean that needs to call an RPG program on the AS400. I've looked at code throughout this site to compare and it looks the same. My problem is I'm getting an error when I try to run it.
"com.ibm.db2.jdbc.app.DB2SQLException2: [IBM][JDBC Driver][14012] The index for the parameter is not valid."
Here's my code:
CallableStatement stpCall ;
String sql = "CALL LIB.CHECKLOGIN ( ?, ?, ? )" ;
try {
Connection connection = null;
connection = ivDataSource.getConnection();
stpCall = connection.prepareCall( sql ) ;
stpCall.setString( 1, ivUserID ) ;
stpCall.setString( 2, ivPassword ) ;
stpCall.registerOutParameter( 3, Types.INTEGER ) ;
stpCall.execute() ;
} catch (Exception e) {
System.out.println(e);
I've tried it a couple different ways and still get the same error. So if anybody can let me know what I'm missing or what I'm doing wrong I would greatly appreciate it. Thanks.Thanks jedilowe.
Here's the code I'm trying to run:
CallableStatement stpCall ;
String sql = "CALL CHECKLOGIN ( ?, ?, ? )" ;
Connection connection = null;
connection = ivDataSource.getConnection();
try {
stpCall = connection.prepareCall( sql ) ;
stpCall.setString( 1, ivUserID ) ;
stpCall.setString( 2, ivPassword ) ;
stpCall.registerOutParameter( 3, Types.INTEGER ) ;
stpCall.execute() ;
ivError = stpCall.getString(3) ;
} catch (Exception e) {
e.printStackTrace();
I'm looking through the stderr log now. Most of if looks like a foreign language, but do you have an idea of what to look for? Anything specific? Here's a few lines from the log:
com.ibm.db2.jdbc.app.DB2SQLException2: [IBM][JDBC Driver][14012] The index for the parameter is not valid.
java/lang/Throwable.<init>(Ljava/lang/String;)V+4 (Throwable.java:94)
java/sql/SQLException.<init>(Ljava/lang/String;Ljava/lang/String;I)V+1 (SQLException.java:43)
com/ibm/db2/jdbc/app/DB2SQLException2.<init>(Ljava/lang/String;Ljava/lang/String;I[B)V+1 (DB2SQLException2.java:281)
com/ibm/db2/jdbc/app/DB2SQLException2.generateException(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;Ljava/lang/String;I[B)Lcom/ibm/db2/jdbc/app/DB2SQLException2;+19 (DB2SQLException2.java:260)
com/ibm/db2/jdbc/app/DB2PreparedStatement.beforeSetXXX(I)I+86
Can anyone decifer this mess and based on the code above, tell me what the heck is wrong with the code!!! I've been fighting this for almost a week now. Thanks for all your help. -
How to call other execs from java application
What is the best way to make a call to execute an external executable written in another language (i.e. c++ or ada95) from within a java application?
Hi,
Runtime.getRuntime().exec(new String[]{"C:\\Office\\winword.exe"});
you should catch IOException as well.
Phil -
Help .. I need to call Exe program from java & run it quickly
Hi...
I have an Exe program ..
when it run in windows ( called by windows ) it takes 300 M.S
but when we called it in java It takes 3000 M.S .. Why..
where is the problem ..
... Help please
Thank u..What are you doing with the input and output streams of the spawned process?
-
hello everyone
I have question
I need to call c program from java
I don't have problem with application or exe file in c it is working but when I call it from java it doesn't work there is no error but it doesn't work because when I execute the c program the black screen must be appeared so that I can enter the input file and then it produces the output file but in java I cann't see the black screen so please can you tell me the problem
I have used the following code to call c from java:
String line;
String output1 = "";
Process p = Runtime.getRuntime().exec("cpp.exe");
BufferedReader input = new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
output1 += (line + '\n');
input.close();Hi,
Try this in your code
p.waitFor();It is for waiting of the process till the completion of the I/O.
Regards -
How do I call a C++ program from Java?
I've tried using Runtime.exec to call my C++ program from Java but I don't think I'm doing it correctly. Could someone explain how to properly use it? Here's what I'm trying (this is in an applet that is only going to be running on an intranet so only PCs in my LAN will be affected):
Runtime runtime=runtime.getRuntime();
Process proc =runtime.exec("mkdir C:\\Test");What do you expect your operating system should do with a command "mkdir"? It doesn't understand this. "mkdir" is a shell command, so you need to execute the shell:
runtime.exec("cmd /c mkdir C:\\test"); -
How to Call abap functn/program from java layer
Hi all,
I have to develop a program which has to call abap function/program from java side or how to call a abap program through java ..
pls send me related links or explanations.. dont send unrelated answers..
Regards,
Arivarasu SHi,
You mean accessing ABAP functions from J2EE perspective, then I think we can do this by using SAP Java Resource Adapter and also through webservices.
SAP Java Resource Adapter (SAP JRA) can be used as an add-on for the SAP JCo SAP JRA enables the implementation of standard interfaces from diverse J2EE servers to the SAP JCo in the SAP Web AS. The SAP JRA thus simplifies
communication with ABAP within heterogeneous J2EE landscapes.
Go through the following links which has Good documentation on how to achieve this
Accessing BAPIs Using the SAP Java Resource Adapter
[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ad09cd07-0a01-0010-93a9-933e247d3ba4]
Connectivity and Interoperability
[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/326d82e5-0601-0010-fca4-9caf27b89c26]
Finally with WebServices. Accessing SAP Business Functions (ABAP) via Web Services
[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/06adbf03-0a01-0010-f386-d8e45561a3c4]
Regards
Raghu -
Call visual prolog program from java
Hi friends,
is there someone help me to call ( run) prolog program from java.
i write a parser with Javacc parser generator and stored parsed information in prolog database and I want create some query in java that work in the prolog file.
how can i combine java and prolog programs. i used visual prolog.
Can someone help me?
Thanks you in advance.
yours sincerely,
ksuSince visual prolog can produce dll's, you can use JNI:
http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html -
Calling javaFX script from Java program
I am trying to call JavaFX script from a simple Java program. code as follows:
import java.io.*;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class My{
public static void main(String[] args) {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByExtension("fx");
try {
InputStreamReader reader = new InputStreamReader(My.class.getResourceAsStream("first.fx"));
engine.eval(reader);
reader.close();
} catch (Exception e) {
e.printStackTrace();
my first.fx file code is here:
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;
Stage {
title: "My First JavaFX Sphere"
scene: Scene {
width: 250
height: 250
content: [
Text {
font: Font { size: 24 }
x: 20, y: 90
textAlignment: TextAlignment.CENTER
content:"Welcome to \nJavaFX World"
} //Text
] // content
} // Scene
} // Stage
I am not able to run My.java. runtime error as follows:
java.lang.NullpointerException
Kindly correct me, where I am wrongI am able to call .fx file from Java. Thank you all for helping me to resolve this problem
Regards,
Ritu
Maybe you are looking for
-
Material staging time in sales order
Hi, I was trying to implement work times for shipping point and came across this scenario. I have an order that is past due. I have moved in plenty of stock so that a MAD of today is possible. There is no pick pack/Loading or transportaion scheduli
-
Does anyone else think that the AppleMac group of products are marketed in a greedy way? I have MacBook Pro 10.5.8 with Leopard and am now told that I have to upgrade to Snow Leopard so that my system can download the relevant iTunes upgrade to sync
-
I am considering creating a book made with iBooks Author but have a couple of unanswered questions. What determines how Apple chooses whether my book can make it into the ranks of being a paid book? In other words, I don't want to put a whole bunch o
-
Composite SAP Note 1261193 : HCM Authorizations Documentation
Hi Team, For what it's worth, I have consolidated all the relevant Support notes, in the field of HCM authorizations, during my project involvements. Composite SAP Note 1261193 : HCM Authorizations Documentation Symptom
-
Job to Import Transport of Copies
Hi, we are implementing CHARM. In case of regular correction, when i say TEST Transport, it creates copy of that transport and release so that copy is in Buffer of quality system. But i want to automate that process. My question is , is it possible t