External system commands in java application

I'm trying to run a molscript command in Unix, in a java application. I want to view a molscript graphic via the application. I have been using the following command
Process p = Runtime.getRuntime().exec("molscript -opengl < " + file);
Is this possible? Ihave ben able to run simple Unix commands such as 'ls' or 'dir' through the application but when I try a molscript command the error says
java.io.IOException: molscript: not found
Perhaps somebody could help me on this subject?

The standard input redirection in:
molscript -opengl <filenameis handled by the command interpreter, that is, one of the shells.
"sh","-c","molscript -opengl <filename"

Similar Messages

  • Calling the system commands in Java

    Hi All,
    How to call the system commands in java other than using
    exec() function.For eg, in my linux machine i have used p.exec("exit") to exit from a cshell to the prompt but it is not working.Is there any other solution for this one. Pls. do provide a solution for this.It is quite Urgent.
    Thanks,
    m.ananthu

    Why not SEARCH THE F*ING FORUMS!! This has been answered SO MANY TIMES

  • Can I execute MySql's command from java application?

    Can I execute MySql's command from java application? And how?
    For example :
    load data local infile 'D:\\myData.txt'
    into table myTable
    fields terminated by ';'
    lines terminated by '\n';

    1. get the jdbc driver for mysql from the mysql site at: http://dev.mysql.com/downloads/connector/j/5.0.html
    2. follow the installation instructiions... which you'll also find in your mysql manual...
    Happy travels. Keith.

  • How to invoke Default printer of my system by using java application

    I need to invoke default printer of my system by using java application ? could u plz help me out with sample code?

    VoodooMagic.getDefaultPrinter().print();
    http://www.javaworld.com/javaworld/jw-10-2000/jw-1020-print.html
    Look for more at Google.

  • How to run system commands from JAVA

    Hi Friends,
    How to run windows system commands from JAVA
    Runtime r=Runtime.getRuntime();
    r.exec("dir");
    Throwing following Exception
    CreateProcess :dir error=2
    Thanks in advance
    Hamsa

    Hi ,
    in Windows NT this is not possible, you can use the following :
    Runtime r=Runtime.getRuntime();
    StringBuffer sbuf = new StringBuffer();
    String dir = new String();
    java.lang.Process proc = r.exec("cmd /c dir");
    InputStream is = proc.getInputStream();
    int ch ;
    while((ch=is.read() ) != -1)
    sbuf.append((char)ch);
    is.close();
    dir = sbuf.toString();
    System.out.println(dir );

  • Running System Commands using Java

    HI,
    I am developing an application using java which requires some system commands to be run.For example i have to write a java function which can program the windows scheduler to run a particular executable at some time & another one to initiate an ftp.I however do not know how to execute the corresponding commands from java.Is there any way or some specific api(similar to the system command in c) that i can use to perform these operations.I am using j2sdk 1.4.0_01 on a win 98 machine to develop the application.

    See [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html]java.lang.Runtime

  • External System command is not working

    Hi Experts,
    I have a requirement to copy some files (K&R ) from one directory to another directory on my application server. For that I made one external operating systems command through Tcode sm69.
    I took operating system as "DOS" and put the operating system command
    "copy d:\usr\sap\e70-trans\data\r900425.e70 d:\usr\sap\trans\test"
    and left the "Parameters for operating system command" blank. I executed it by FM SXPG_COMMAND_EXECUTE., it gives me an error message
    Can't exec external program (No such file or directory)
    WaitForSingleObject failedwith %d (No such device or address)
    the above DOS command is working fine when i am running it directly from dos prompt.
    I didn't give any RFC in above FM. and changed the operating system to DOS by default it comes as Windows NT, gave the command name. Remaining things were defaulted.
    My application server is on Windows Server 2003.
    Can you please let me know what I am missing?
    Thanks
    Yogesh Gupta

    Hi,
    Since you ave tried it from command prompt, simplest would be create a batch file & include your copy command in that & in SM69 define a new command say ZCOPY, give operating system command as batch file name along with full path. Test the above via SM49. If it works then just use:
      CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
             EXPORTING
                commandname            = 'zcopy'
              additional_parameters  = w_additional_parameters
                status                              = statusline
             TABLES
                exec_protocol                       = t_copy
             EXCEPTIONS
                no_permission                       = 1
                command_not_found                   = 2
                parameters_too_long                 = 3
                security_risk                       = 4
                wrong_check_call_interface          = 5
                program_start_error                 = 6
                program_termination_error           = 7
                x_error                             = 8
                parameter_expected                  = 9
                too_many_parameters                 = 10
                illegal_command                     = 11
                wrong_asynchronous_parameters       = 12
                cant_enq_tbtco_entry                = 13
                jobcount_generation_error           = 14
            OTHERS                              = 15
    I hope this helps,
    Regards
    Raju Chitale
    Edited by: Raju Chitale on Apr 15, 2009 8:16 AM
    Edited by: Raju Chitale on Apr 15, 2009 8:18 AM

  • System Exit from JAVA Application

    I need to call Oracle Reports from a JAVA application.
    Does anyone have experience in this area?
    One thing that comes to mind is to make a system exit and call the reports from the command line. Is this possible to be done? How?
    Thank you for any help or suggestions.
    Tina.

    the best way to access the oracle database is via jdbc (see http://java.sun.com/products/jdbc/ ). if, however, you specifically need to run some oracle reporting s/w then you could run it as a separate process from your java application using Runtime.exec() (see http://java.sun.com/j2se/1.3/docs/api/java/lang/Runtime.html#exec(java.lang.String) ) which returns a Process object. you can then read its output with the Process object's getInputStream() method (this gives you an InputStream which is the data piped from the standard output stream of the process).
    hth,
    jonesy (sun developer technical support)

  • Urgent!! running system command in java

    i am trying to run system command(windows) in java. I am getting
    exception as java.io.IOException: CreateProcess: c:\dir
    Please Help.
    Here is the code
    import java.io.*;
    public class RunCommand {
    public static void main(String[] args) {
    try
    //run dir command
    Process p = Runtime.getRuntime().exec("c:\\dir");
    BufferedReader stdInput=new BufferedReader(new
    InputStreamReader(p.getInputStream()));
    BufferedReader stdError =new BufferedReader(new
    InputStreamReader(p.getErrorStream()));
    //read the output
    System.out.println("here is the output:\n");
    while((s=stdInput.readLine())!=null){
    System.out.println(s);
    System.out.println("here is the error if any");
    while((s=stdError.readLine())!=null){
    System.out.println(s);
    System.exit(0);
    }//end try
    catch (IOException e)
    System.out.println("exception Happened" );
    e.printStackTrace();
    System.exit(-1);

    It works fine if you replaceProcess p = Runtime.getRuntime().exec("c:\\dir");withProcess p = Runtime.getRuntime().exec("cmd /c dir");And don't forget to define your s variable.

  • Executing system command in java

    I am trying to set ORACLE_SID value from java application.
    when i echo $ORACLE_SID it shows me the old sid value
    please help
    my code --->
    import java.util.*;
    import java.lang.*;
    import java.io.*;
    public class runSysCommand{
         public static void main(String args[]){
         String osName=System.getProperty("os.name");
         System.out.println("the OS name is :" +osName);
         String s=null;
         String[] cmds = {"/bin/ksh","-c","export ORACLE_SID=pd3"};
    try
    Process p = Runtime.getRuntime().exec(cmds);
    BufferedReader stdInput=new BufferedReader(new
    InputStreamReader(p.getInputStream()));
    BufferedReader stdError =new BufferedReader(new
    InputStreamReader(p.getErrorStream()));
    //read the output
    System.out.println("here is the op:\n");
    while((s=stdInput.readLine())!=null){
    System.out.println(s);
    System.out.println("here is the error if any");
    while((s=stdError.readLine())!=null){
    System.out.println(s);
    System.out.println("the OS name is :" +osName);
    System.exit(0);
    }//end try
    catch (IOException e)
    System.out.println("exception Happened" );
    e.printStackTrace();
    System.exit(-1);
    }

    When you execute "/bin/ksh," you get a new shell - with a new environment. When you close the shell, it's environment (and any changes) go away. What you will need to do is write a shell script that takes the value as a parameter - the script then sets the environment and runs whatever other program you want to specify. When the script exists, the environment will also disappear.

  • How to load externally libraries on a java application

    Hi,
    I've created a java application which i've compiled as an executable file. I want to cut the size of the exe down, and so i'm trying to load some libraries externally, instead of the IDE including it on the executable i created. So basically i've got my application.exe file, and in the same directory i have an images directory and a lib directory. How do i access the jar files on the lib directory? Some examples of code would be great. At the moment my lib directory contains mssql.jar files.
    thanks

    no it hasn't bundled the jvm into the app. the app is 438kb without the jar libs included. The libs add another 400+kb . i've separated the image files without problems. This loads the images from a directory called images. The issue is just how load the libs.

  • Execute DOS command from java application

    Hello,
    I want to execute a DOS command (MOVE, in order to move an image from a folder to an other) from a java application. How can I do this?
    Francesco

    Yes I have tested it and it is working but only when executing a bacth file. For instance:
    Runtime rt = Runtime.getRuntime();
    try{
         Process proc = rt.exec("move.bat");
    }catch(Exception ex){
         ex.printStackTrace();
    }and the command in move.bat is:
    move c:\\temp\\*.gif C:\\temp2
    You don't have to use double slashes in batch files, only in Java. But anyway it is working both ways.
    It is not working when you try to execute the command without the batch file:
    Process proc = rt.exec("move c:\\temp\\*.gif C:\\temp2"); -> this will not work.
    It should work. Try to execute another command to see what happens.

  • Setting the system property in java application

    Hi,
    I want to make a connection to https://URL through my java application class
    which will be deployed in the weblogic server. Could any one help by
    telling how could I set the system properties in my java application. If I
    pass the value in the java class do I have to change any value in the
    weblogic.properties file.
    Thanks in advance and looking forward to hear your valuable suggestion.
    Sirisha

    System.getProperty(..)
    System.setProperty(..) is this what you are asking for?
    This gets and sets the system (your machine) environment properties
    Filip
    In article <396d0a93$[email protected]>, [email protected] says...
    >
    Hi,
    I want to make a connection to https://URL through my java application class
    which will be deployed in the weblogic server. Could any one help by
    telling how could I set the system properties in my java application. If I
    pass the value in the java class do I have to change any value in the
    weblogic.properties file.
    Thanks in advance and looking forward to hear your valuable suggestion.
    Sirisha
    Filip Hanik
    Software Architect
    XMarkstheSpot.com
    [email protected]

  • Using Unix commands from Java Application

    Hi,
    I need to write an Java application such that could run Unix commands in a Unix box.
    For example, my Java app needs to log in the Unix box, change directory (cd), create new folder (mkdir), list the current files in folder (ls), mount a new device (mount), etc.
    Thank you very much.
    Hung

    you can use java.lang.Runtime.exec to invoke OS commands, but if you're going to be completing a sequence that complicated and need to manage error handleing well, it might be best to just invoke a native method or write a shell script that does all of that stuff and then invoke that script via Runtime.exec . The Runtime class has limitations when you start invoking processes that require user input (like 'su'). Search the forums for more extensive examples on how to use Runtime.

  • How to execute any cmd command from java application?

    Hi all,
    How to execute or call any command of cmd from java application??
    Is there any method to do so??
    Or, is it possible to do it using Runtime.exec() ??? And if so, how to use it, please explain with ab example...
    I'll highly appreciate....
    Thank you.

    If google would be the best option, then I would not be on Sun's forums and I would not have asked experts like you, sir !! :-)
    Neway, I got the solution from PhHein !!
    Good link indeed..
    Cheers..

Maybe you are looking for

  • How to consolidate iTunes from MAC & PC on to a NAS box?

    === Background === I've got 2 MACs & 2 PCs (WinXP) and I want to get the iTunes data consolidated to the network. I've got iTunes data (including purchased songs) on both MACs and 1 PC. MACs have iTunes 8.02. PC has iTunes 7.4.3.1 (but I can upgrade

  • Buttons...Seem 2 Be Frozen!!

    Help! My I-Pod Is Working...But Not Working! The Screen Turns On, The Battery Goes Down And Up, The Restart Works And The Hold Works...But What Doesn't Work Is The Other Buttons. At The Moment My I-Pod Screen Is On The Start Screen, But My Select, Me

  • Re: File Input Streams FileNotFoundException

    Hi, I'm having problems with file input streams. The program is supposed to read from an external file but when I run it in Sun ONE Studio 4 (update 1), it gives me a FileNotFoundException (The system cannot find the file specified). The file, class.

  • Problems Problems Problems

    Ok, first off I am having a problem on my startup drive on occasional restart I am getting the blicking system folder. Do another restart and it is fine. My system runs good with no errors while running, just on restarts. I have done all of the commo

  • Failure to deploy dimension - ORA-01031: insufficient privileges?

    Hi all, 1. I imported a mdl file. 2. Then I registered all locations 3. Then I deployed all staging area objects successfully. 4. Then I deployed sequences and tables in the target module successfully. 5. However, when I want to deploy the dimensions