How to execute programs by java (shell excecute)

i need to know how to execute a prog or a system call by java and pass tp it an argument

Hi, look at the java.lang.Runtime class.
eg Runtime.getRuntime().exec(<command>, <arguments>);
;) Patrick

Similar Messages

  • Does any one know how to execute program in Jump developer desktop

    hi,
    Does any one know how to execute program in Jump developer desktop,
    actually i copied the hello world project from my eclipse workspace to jump
    developers workspace and once i run the program it asks for the main class
    and then i gave main class as my HelloWorld Class,it generates error as
    java.lang.NoSuchMethodError: main
    Exception in thread "main"
    Can any one help me to come out of this problem.....
    Thanks
    MRaj

    i solved it,
    thanks
    MRaj

  • How to execute sql-queries through shell scripting in linux?

    How to execute sql-queries through shell scripting in linux?

    http://www.oracle.com/technology/pub/articles/saternos_scripting.html
    Two simple examples:
    #!/usr/bin/env bash
    set_orafra () {
       orafra=`echo 'set heading off
       select name from v$recovery_file_dest;
       exit' | sqlplus -s / as sysdba`
    set_orafra
    echo $orafra
    #!/usr/bin/env bash
    export ORACLE_SID=instance_name
    export ORACLE_HOME=/path_to_oracle_home_directory
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export PATH=/$ORACLE_HOME/bin/$PATH
    $ORACLE_HOME/bin/sqlplus -s <<EOF
    connect scott/tiger@my_instance_name
    INSERT INTO table VALUES (sysdate);
    exit
    EOFEdited by: Markus Waldorf on Sep 17, 2010 12:19 AM

  • How to execute programs on different hosts/ severs?

    HI all,
    In my SAP 4.6C system, two instances are running.
    I would like to execute programA on instance1 and programB on instance2.
    How could this be achieved?
    thanks in advance,
    holger

    @Srinivas:
    You can execute these two programs online. See how:
    - Write a RFC FM that executes an given report
    - Call this FM by coding
    CALL FUNCTION 'FUNCTION1'
      DESTINATION dest
    - this FM again calls another RFC FM:
    CALL FUNCTION 'FUNCTION2'
      STARTING NEW TASK task
    taking this way, both jobs will run 'online' (in dialog process).

  • How to execute a custom java code from the process

    Hi All,
    I'm writing a process to generate the PDF and it works fine. Now, at the end or in the middle of the process, i would like to execute/write a java code then it will be invoked when the process running. Assume not using web service, is there another way? samples how to write custom code?
    Thanks,

    The Execute Script service allows you to execute java code on a particular step.
    A more robust solution would be to create a custom component for your custom code.
    Jasmin

  • How to execute mimetex in java program

    hi,
    I am working with an application which has a chat window with a feature of displaying mathematical equation with the help of mimetex. Basically I want to know that how I can call a program like mimetex with some parameter that it takes and find the output for same.
    thanx
    manoj

    You may be able to call WsImport's main() method from your code, something like this:
    import com.sun.tools.ws.WsImport;
    String[] args = {"put", "your", "arguments", "here"};
    WsImport.main(args);(Make sure that the webservices-tools.jar file is on the classpath, since that's the one containing the WsImport.class file - you'll probably need the other webservices jars too).

  • How to execute commands from Java

    hi,
    i m trying to execute a CVS command from a java environment. i m writing this code to create a user. for this i m executing this cvs command "cmd /c cvs passwd -r <username> -a <new-username>"
    after executing this cmd the command prompt will prompt for a pasword and then after entring the password i have to retype the password for confirmation. the existing code execcutes the command but i don t know how to read the prompt for password.
    <code>
    import java.io.*;
    import java.lang.*;
    public class first {
    public static void main(String[] args) {
    try {
    Process p = Runtime.getRuntime().exec("cmd /c cvs passwd -r gopalakrishnan_k -a ram");
    InputStreamReader reader=new InputStreamReader(System.in);
    BufferedReader OptFromCmd = new BufferedReader(new InputStreamReader(
    p.getInputStream()));
    BufferedReader fromKeyboard = new BufferedReader(reader);
    BufferedReader stdError = new BufferedReader(new InputStreamReader(
    p.getErrorStream()));
    OutputStream stdOut = p.getOutputStream();
    String s;
    String pswd = "mahesh";
    System.out.println("Success");
    int i = 0;
    while ((s = OptFromCmd.readLine()) != null) {
    //s = OptFromCmd.readLine();
    i++;
    System.out.println(s);
    System.out.println(i);
    if (i > 1) {
    stdOut.write(pswd.getBytes());
    stdOut.flush();
    System.out.println(
    "Here is the standard error of the command (if any):\n");
    while ((s = stdError.readLine()) != null) {
    System.out.println(s);
         /* Your Password Here */
         String password="Password Please";
         stdOut.write(password.getBytes());
    stdOut.flush();
         stdOut.write(password.getBytes());
    stdOut.flush();
         /* Your Password here */
    OptFromCmd.close();
    stdError.close();
    stdOut.close();
    } catch (Exception e) {
    e.printStackTrace();
    </code>
    [o/p]
    this program gives the output as
    adding the user <username>
    password:
    now i need to enter the password from java envronment and provide it in the command prompt .
    then it prompts for the password again for confirmation so i have to retype the password again
    how to acheive this.

    String abc[]={"sh","-c","/dir1/dir2/dir3/scanVirus/uvscan --clean -- delete --exit-on-error ../*.*>abcde.txt"};
    Runtime runtime = Runtime.getRuntime();
    Process p = runtime.exec(abc);
    when it founds any infected file the process is not terminated correctly and it gives the following error :
    "java.lang.Exception: Process failed to terminate correctly"
    but it deletes the infected file.
    and running the program second time (after deletion of infected file), it executed fine.
    Wating for help.
    Regards,
    Sundeep.

  • How to execute vbscript through java

    hi i m trying to run vbscript (that accept some command line arguments) through java .
    my vbs file is stored in c: drive
    purpose of vbs file : to map network drives.
    i normally run it from command prompt using following syntax
    c:\cscript map.vbs l: \\10.22.122.35\d$ <username> <password>
    code in map.vbs
    map.vbs
    Dim objNetwork
    Set objNetwork = WScript.CreateObject("WScript.Network")
    strLocalDrive = WScript.Arguments.Item(0)
    strRemoteShare = WScript.Arguments.Item(1)
    strPer = "FALSE"
    strUsr = WScript.Arguments.Item(2)
    strPas = WScript.Arguments.Item(3)
    objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, strPer, strUsr, strPas
    my problem is i can easily accomplish this by using .batch file but i dont want to reveal my username and password
    i just want to know is there any way thru which i can somehow link java program with dos command and execute vbs file
    from my java program.
    the code that i have got is not working properly or has to be modified to work.
              String os = System.getProperty("os.name").toLowerCase();
         if (os.indexOf("windows") != -1)
              String[] command = new String[]{"cmd.exe", "/c","cscript","c:\\map.vbs", '"'+strDrive+'"','"'+strPath+'"',"<username>" ,"<password>"};
              Runtime.getRuntime().exec(command);
    Kindly help me as this is very urgent.

    prompt for the login, the password, and the new share name, and store them in variables, then, you can do something like:
    Runtime.getRuntime().exec("net use " + sharenameVar + " \\\\HOST\\share /user:HOST\\" + userVar + " \"" + passwordVar + "\"");with the following values:
    HOST: PC10
    user : toto
    pass : a password
    sharename: I:
    it will result in :
    net use I: \\PC10\share /user:PC10\toto "a password"
    this will map the new share with the given credentials ; there is no need to add some complexity by using a vbscript to do that

  • How to execute program in remote server?

    In my code I am executing a program that resides on another
    server. But when I execute the program the server where the code is
    resided runs the program and sucks up CPU.
    How can I make it execute the program in the remote server? I
    don't want it to just fetch the exe and run it locally. I want it
    to execute the program IN the remote server, using ITS resources.
    The remote server is a network share, \\server2 for example.
    Any thoughts?

    You should be able to use <cfexecute...> to do this,
    you will have to
    make sure all the connections and permissions are set up.
    Just remember that by default, at least on windows systems,
    CF is
    configured to only have access and permissions to the local
    system, you
    will need to modify this if it has not been done.

  • How To Execute SQL Statements From Shell Scripts?

    I need to extecute some SELECT statements from a shell scripts. Could anybody kindly tell me how to do that, or which document i should refer to ? Thank you very much!

    You can execute SQLPlus with the SQL in a file (sqlplus -s @<sql-script>).

  • Runtime (execute programs with java)

    Hello,
    I need your help. I need to run Internet Explorer when a menu item is clicked in a JMF Applet. Is this the code?
    //this is the class I created to run Internet Explorer
    class CorreIE {
    public static void main(String args[]) {
    try {
    Runtime cie = Runtime.getRuntime();
    Process prcs = cie.exec("C:\\Program Files\\Internet Explorer\\iexplore.exe");
    } catch(IOException ioe) { System.out.println(ioe); }
    //this is the action listener I created for the event
    if (ae.getSource()==ajuda) //abre o internet explorer com o ficheiro de ajuda
              CorreIE cie = new CorreIE();
              cie.show();
    IT DOESN'T WORK.... Please help!
    Thanks,
    XonaDick

    You have your code in a main method which will work if you run it stand alone
    Instatiate your class eg: RunTimeExec rte = new RunTimeExec();
    then access its run method eg : rte.runIExplorer();
    Try this
    import java.io.IOException;
    class RunTimeExec {
    public RunTimeExec(){
    public runIExplorer(){
    Runtime cie = Runtime.getRuntime();
    try {
         Process prcs = cie.exec("C:\\Program Files\\Internet Explorer\\iexplore.exe");
    } catch (IOException e) {
    // TODO Auto-generated catch block
         e.printStackTrace();
    it does work

  • How to execute program from any dir?

    For example javadoc.exe is in D:\jdk1.3\bin.
    And I need to execute it from current dir.

    If you are running a Javadoc from DOS or the WinNT command shell, the proper command is
    D:\JDK1.3\BIN\JAVADOC.EXE <params>
    If you want to avoid typing this each time, type the following at the command prompt:
    PATH=%PATH%;D:\JDK1.3\BIN
    The command JAVADOC.EXE will then function without specifying the directory. The proper action is normally to add the JDK to your PATH environment variable when installing it.
    In Windows 2000, you can modify your PATH variable by right-clicking My Computer and selecting the Advanced tab followed by the Environment Variables button. It is usually best to edit the PATH in the System Variables section to ensure that all users on your system receive the updated PATH variable.
    In Windows 95/98, I -think- that the appropriate action is to open your AUTOEXEC.BAT file and locate the last line that says PATH=<stuff>. Add the following to that:
    Old: PATH=C:\ADIR;C:\ANOTHER
    New: PATH=C:\ADIR;C:\ANOTHER;C:\JDK1.3\BIN
    I think this is appropriate for Win 95/98, but I'm not sure. Correct me if I'm wrong.
    Good luck!

  • Windows executable program in java

    hi
    i need to write a program which is windows executable and when it execute it automatically call a URL and it open the web page.But i am not able to find any idea.can any one help me??

    Hi
    i think you need to create JAR file of your programm to make it windows executable.
    for the URL you need to create one JSP file like below
    <html>
    <script type="text/javascript">
    function openUrl(){
    var url=document.getElementById('link').value;
    window.location=url;
    </script>
    <body onload="openUrl()">
    <input type="hidden" id="link" value="http://www.yahoo.com">
    </body>
    </html>
    another lots of way
    you can get it here
    [http://www.htmlgoodies.com/beyond/javascript/article.php/3471221]
    [http://www.pageresource.com/jscript/jwinopen.htm]
    [http://www.devx.com/tips/Tip/14410]
    Thanks
    ~Chirag

  • How to execute modulepool program

    hi all,
    how to execute programming type M
    plz send detail informaton regarding that one

    Hi
    You cannot execute a Module pool program as you execute other ABAP programs.
    For executing a Module pool program, <b>create a z-transaction code</b> for that M-program
    & then execute the z-transaction code.
    Goto Transaction <b>SE93</b> to create a z-transaction code for that m-program.
    Then execute the Z-Transaction code.
    Kindly reward points for helpful answers!
    Best regards,
    Thangesh

  • Executable files in Java...

    Hello, all. I am fairly new to Java and have a question. I know that Java is an interpreted language, and all files are run throught the interpretor as they run. Is there a way to create an executable file (i.e. .exe in Windows) to run a Java app? I am interested in application programming and I have dabbled in C++ and VB, and with them it is easy to create executables. Can this be done in Java? Any help with this would be great. Thanks a lot, guys!
    James McConnell
    Your Resident Musician

    Hello, all. I am fairly new to Java and have a
    question. I know that Java is an interpreted
    language, and all files are run throught the
    interpretor as they run. Is there a way to create an
    executable file (i.e. .exe in Windows) to run a Java
    app? I am interested in application programming and I
    have dabbled in C++ and VB, and with them it is easy
    to create executables. Can this be done in Java? Any
    help with this would be great. Thanks a lot, guys!
    James McConnell
    Your Resident MusicianOf course, my friend! There's a way to do it. If you download the Java IDE from this website, SunOne Community Edition version 4, you can accomplish that ( at least that's the way I've done them). This Java IDE creates a folder that is executable in Windows, it's called a JAR file (Java ARchive executable file), or run it on any operating system that is Java Enabled.
    With SunOne, you can do it this way:
    1) Click on File
    2)Select New
    3) Then select JAR Archive
    4) In the wizard, follow the steps which tell you the java files that are needed to run the application (because sometimes a programs comprises more than one class)
    5) Create a Manifest
    If this doesn't work for you, find information about JAR Archive files on the Internet because this is the way to make executable programs in Java. Good Luck!!

Maybe you are looking for

  • Cant get out of CMOS

    Hi Can anyone help me. I have just upgraded my computer. The package included the AMD 64 3000+ 2.0GHz,MSI K8T NEO-FSR, Corsair Value Select PC3200 DDR 512B and can be found at : http://www.komplett.co.uk/k/ki.asp?sku=112188&cks=PRL. I have also purch

  • FORM RUNTIME record=collect is not working.

    Hi FORM RUNTIME record=collect is not working which is set to user level.what to do? rgrds

  • Things to monitor on a Database

    What is Logical I/O, Physical I/O, Events waits, Call rates, Miss rates, Sessions and what is their importance. Thanx.

  • THIS IS MY SPEC "URGENT HELP NEEDED"

    Posting date     VBRK – FKDAT     SO     Y      Fields to be retrieved:       VBRK - VBELN       VBRK - FKDAT       VBRK - VKORG       VBRK - SPART       VBRK - KUNAG       VBRK - NETWR       KNA1 - KUNNR       KNA1 - NAME1       VBRP - FKIMG Get the

  • SQL in Input Tables

    I have an input table in a mapping and I need to override the default select query with my own custom query having some filter criteria and some nvls and decode's and other such things. Can anyone let me know where to write the source query override