How to call a external program in java?

Help!!
Is there any method that can a java program can call a external program? For example execute a exe file.
Thanks.

Yes.
Runtime.getRuntime().exec("exactly what you would type at the command line");
But be aware that this is operating-system-specific and full of gotchas. When you run into one of them, come back to the forum and do a search, this is a frequent topic of discussion.

Similar Messages

  • How to call a external program in java program

    for example, if I want to execute internet explore or windows word in java program, how to do it?

    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html

  • 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 S

    Hi,
    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

  • How to call a C program in java PACKAGE

    am trying to call a method implemented in C from java.
    I followed the instructions of sun.java.com tutorial for the simple example of HelloWorld. It works fine.
    BUT, when I try to do the same in a package, I run into a lot of trouble. I did the following :
    1. Created HelloWorld.java in a package GUI/ and compiled it
    package GUI;
    import java.io.*;
    class HelloWorld {
    public native void displayHelloWorld();
    static {
    System.loadLibrary("hello");
    // Call native method through this from other classes
    public void callinghello() {
    callip();
    public static void main(String[] args) {
    new HelloWorld().displayHelloWorld();
    2. javah -jni HelloWorld -- to create HelloWorld.h
    3. wrote HelloWorldImp.c
    4. g++ -Wall -shared -I/usr/lib/j2sdk1.3/include -I/usr/lib/j2sdk1.3/include/linux HelloWorldImp.c -o libhello.so
    -- compiled and created .so file
    5. Set the package directory in Classpath, path and LD_LIBRARY_PATH
    6. When it is run java GUI.HelloWorld
    I get this error
    Exception in thread "main" java.lang.NoClassDefFoundError: OrionGUI/HelloWorld
    Can anyone help me. If you have any links to how to call native methods in package, please let me know. Thanks.

    GOT IT !!!
    I had to change the name of the method in .h file generated by javah command. On doing
    javac -d ../../classes HelloWorld.java
    go to the ../../classes directory (where you have the class file) and do
    javah HelloWorld
    I got a HelloWorld.h file in which I had
    JNIEXPORT void JNICALL Java_HelloWorld_display(JNIEnv *, jobject);
    I added the package name too:
    JNIEXPORT void JNICALL Java_GUI_HelloWorld_display(JNIEnv *, jobject);
    The HelloWorldImp.c file should have the same name (ie with package) and be in the same directory(ie ../../classes)
    compile and build the shared library to get "libhello.so" file
    gcc -c -fPIC -I/usr/lib/j2sdk1.3/include -I/usr/lib/j2sdk1.3/include/linux HelloWorldImp.c
    gives .o file
    gcc -shared -o libhello.so HelloWorldImp.o
    gives .so file
    then run java with the command in my first message. It works.
    Thanks for the reply "thedracle".

  • How to call a C program in java?

    I would like to call a C program (which does not return anything back to the Java program) from a Java class? Or is there any simple example just to do such a task online?
    Thanks.

    two options:
    1) Use JNI and call your C routines directly
    2) Make an executable and call it using Runtime.exec()

  • How to call a external software in java program?

    for example, if I want to execute internet explore or windows word in java program, how to do it?

    // Modified from Just Java
    import java.io.*;
    public class execDir {
    public static void main(String args[]) {
    try {
    Runtime rt = Runtime.getRuntime(); // step 1
    Process prcs = rt.exec("doDir.bat"); // step 2
    InputStreamReader isr = // step 3
    new InputStreamReader( prcs.getInputStream() );
    BufferedReader br = new BufferedReader( // step 4.
    isr );
    String line;
    while ((line = br.readLine()) != null)
    System.out.println(line);
    } catch(IOException ioe) { System.out.println(ioe); }
    Maybe this will help you.

  • How to execute external program in java?

    My question is how to execute an external program in java.
    I need to call a unix command in java.
    Thanks.

    it depends on what you are trying to do. Following are the two methods
    1. Runtime.exec() : this method allows you just to call an external program as a seperate process
    2. JNI (Native Interface) :- As of right now only C and C++ are supported by this method. This method allows you to directly call the C/C++ methods from JAVA

  • How to call SAP Webservice in standalone java program

    Hi,
    In our Java application, we want to use the SAP Webservices. I dont know much about authentication mechanism used by SAP. Can any one please help me with any sample code how to Call SAP webservice in Standalone Jave Program. I searched alot on the web regarding this, but helpless. Please help me.
    Thanks,
    Mohan

    Hi Mohan,
    You need an account for the ES Workplace. I'm afraid this is not free, e.g. check [SAP NetWeaver, Composition Subscription|https://www.sdn.sap.com/irj/sdn/subscriptions/composition].
    But I thought you wanted to play with a WSDL [you already had at hand|Sample code to access BAPI Web services from JAVA required;?

  • When I call an external program from Labview, how can I embed the interface into the front panel?

    I'm running Labiew 6i for Linux. I'm using a system exec.vi to call an external program to do image manipulation (since there is no IMAQ for linux). How can I embed the user interface of the external program into the front panel of Labview?

    As far as I know, the only way to embed other GUIs in LabView is an ActiveX in a container.
    As long as you are using Linux, try to place (moving them on the desktop ) the two windows linked (like those 3 of WinAmp).

  • 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");

  • Calling an external program!

    Salut all, Im using unfortunately Oracle Forms 6i, and I need to call an external program that I have to develop in Java, compiled into .jar. I just wanna use something like java -jar myJar.jar <my params...> but I don´t know how to call external programs from Oracle Forms, in special from 6i.
    I have searched this thread passed (Re: Calling JAVA from PL/SQL but didn´t help me so much.
    Thanks all for patience!

    In version 9 and 10 we have a general way of calling out to java thru the Java Importer functionality.
    If you cannot upgrade to these later versions and you don't need to get data back from the jar file execution you can always use the Host command to call it directly the way you have outlined.

  • How to call a VB application from Java

    Hi,
    does anybody know how to call a VB application from java.
    Would appreciate if you can provide me with an example.
    thanks

    try exec()ing the cad program with the name of the file as a command line parameter...
    Runtime.getRuntime().exec("CADProg.exe Test.prt");
    i have no clue if this will work but it seems like it's worth a try.

  • How to call an external web service from OIM?

    Hi,
    I have a question on how to call an external web service from OIM within e.g. creating user process? How should it be done; through adapter and task in the process?
    Any recomendations?
    Thanks in advance!

    it is not clear to me if you are having problems with calling java code from OIM or if the problem is the web service API.
    Lets do some divide and conquer:
    Can you create a simple java class that just writes a couple of lines to the log? Please attach this code to the OIM task and make sure it runs.
    Once this works we can start looking at the web service call.
    Best regards
    /Martin

  • Before calling an external program, check if the program is allready open

    I need to call an external program to print some labels, so i will use function WS_EXECUTE or the new one DSVAS_DOC_WS_EXECUTE_50 to call my program, but the problem that i have is:
    when I call this function, the program open a small window, and if i have to call it again, it will open another window, and so on... obviously this is not a good solution.
    Is there any one how knows how can i close the program, of perhaps it is enough if there is some way to know if the program is already open.
    Many thanks in advance,
    Miriam

    Hi
    you can use the ABAP Coverage Analyzer.
    OR
    This is a function module we use to limit the execution of a program to one instance at a time.
    DATA: PRG LIKE INDX-SRTFD. PRG = SY-CPROG.
    CALL FUNCTION 'ENQUEUE_ESINDX'
    EXPORTING RELID = 'ZZ'
    SRTFD = PRG
    SRTF2 = 0
    EXCEPTIONS FOREIGN_LOCK = 1
    SYSTEM_FAILURE = 2.
    IF SY-SUBRC NE 0.
    FORMAT COLOR COL_NEGATIVE INVERSE ON.
    WRITE: / 'ERROR: Program Is Already Running'.
    WRITE: / 'Program', PRG, 'has been stopped. Rerun in 1 minute.'.
    STOP.
    ELSE.
    WRITE: / 'OK ',PRG.
    ENDIF.
    Regards,
    Raj

  • Call a c program in java

    i am trying to call a c program in java,can anyone tell me how ot do this using jni

    That has nothing to do with JNI nor java.
    However if you mean an executable, then the will be an OS call, specific to your OS, which allows you to run a process/application. That is the only way you can do it.

Maybe you are looking for

  • Nested Menus Not Appearing in a Custom Panel Fly-out Menu

    I tried to create a menu for a custom panel, using the example which David Clark graciously pointed out to me: http://cssdk.host.adobe.com/sdk/1.0/docs/WebHelp/programmers_guide/cus tomizing_the_ui.htm However, the nested menu items do not appear. I

  • Latest version of pages (5.1) won't open documents created on pages (same version).

    Just a week ago I worked on my documents with no problem. Today, I can't open the documents anymore. I keep getting an error message requiring a newer version of pages. I have removed and re-installed pages - no luck there. I have only 1 version inst

  • Album Starter Edition 3.2

    I used to have pictures stored in the MY CATALOG section of the Photoshop Album. Recently my Dell Dimension 3000 (Windows XP Homne edition) was acting up awfully and I had a clean reinstall done from the installation disc. Unfortunately, my Photoshop

  • App store/itunes wont load

    Just says loading.... forever. am connected to wifi. safari works, mail works, everything works except appstore and itunes. help.

  • Mountain lion error message (fail to restart Mac mini for installation)

    Hi, I successfully downloaded mountain lion and attempted to install it several times on my Mac mini; however, it gives an error message when it wants to restart computer for installation purposes. The error message reads "An error occured while prep