Execute gnuplot from java

Hi,
I want to execute gnuplot from java, I can get the console to open using:
Process theProcess = Runtime.getRuntime().exec("/Java/gnuplot/bin/wgnuplot.exe");But I want it to open gnuplot and open a file, for example 'foo.bat'. I've tried:
Process theProcess = Runtime.getRuntime().exec("/Java/gnuplot/bin/wgnuplot.exe, foo.bat");However this throws a file not found exception, any ideas?
Thanks.

Process theProcess = Runtime.getRuntime().exec("/Java/gnuplot/bin/wgnuplot.exe, foo.bat");
...1 - should there be a comma after wgnuplot.exe?
2 - try providing the absolute path for foo.bat like this:
Process theProcess = Runtime.getRuntime().exec("/Java/gnuplot/bin/wgnuplot.exe /path/to/foo.bat");

Similar Messages

  • Executing jar from java code, then kill parent java code

    Please suggest if there is any best way around on executing jar from java code then killing parent java code.
    a) I have desktop based java application say "Monitor.java" which runs every 5 minutes.
    b) How can I START external java application say "execute.jar" from Monitor.java THEN EXIT Monitor.java
    I tried various options using "ProcessBuilder" and calling bat file but I need Monitor (parent application to EXIT, immediately after calling child (execute.jar)
    Try1) ProcessBuilder builder = new ProcessBuilder("java -jar execute.jar");          
    Process process = builder.start();
    Try2) Runtime r = Runtime.getRuntime();
    Process p = null;
    p = r.exec(new String[] { "cmd", "/c", "start C:/temp/Test.bat" });

    I have a requirement to transfer data from one db to another db from Java Application Layer.Maybe, maye not. We get all sorts of weird "requirements" - which are nothing but thoughts or proposed solutions.
    But,
    Did the "requirement" mention whether the table existed already or not in the target database? - If not, did it tell you to create it - drop/create it?
    Did the "requirement" deliver some explanation to why this copying was neeeded? - Are we talking replication? - Or a one time cloning?
    Etc, etc,
    Personally I would always argue against a "reuirement" like that. - It just isn't the way to do it. Period.
    Regards
    Peter
    P.S: If you are satisfied with what COPY does, then you could let Java make an OS call and do it from there?

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

  • Execute ConcurrentRequest from java program

    In order to execute concurrent request from java program are this 3 lines enough :
    1)ConcurrentRequest concurrentrequest = new ConcurrentRequest(oadbtransaction.getJdbcConnection());
    2)int i = concurrentrequest.submitRequest("some value", " some value", "some value", null, false, vector);
    3)oadbtransaction.commit();
    *******************************8
    I am asking because while executing ConcRequest from PL/SQL I have to call a functin : fnd_global.apps_initialize(user_id ,resp_id, app_id) prior to executing FND_REQUEST.SUBMIT_REQUEST.
    Is there any equivalent in java for apps_initialize?
    thanks in advance.

    hi
    u can call the FND_global using callable statement
    DBTransaction txn = getDBTransaction();
    CallableStatement cs =
    txn.createCallableStatement("begin fnd_global.apps_initialize(:1, :2,:3);end;");
    try
    cs.setString(1, getOADBTransaction().getUserId() );
    cs.setString(2, getOADBTransaction().responsibilityId());
    cs.setString(3, getOADBTransaction().getApplicationID());
    cs.execute();
    cs.close();
    catch (SQLException sqle)
    try { cs.close } catch (Exception(e) {}
    throw OAException.wrapperException(sqle);
    thanx
    Pratap

  • Executing DLLs from Java using JNI vs Runtime.exec()

    I am trying to understand the best way to execute a dll using java. The dll I am testing with takes a few input parameter. If I use JNI with System.loadLibrary("dll"); what do I need to do to pass the arguements in as well? Can I just add the arguements in the java code like private int xyz = "value"; and expect that the dll will accept them or is there special definitions I have to set up in the dll to make it work?
    Alternatively I was looking at using Runtime to execute the dll by using Runtime.exec("dll param1 param2",env,filePath); Does anyone know if there are drawback to doing it this way vs. using JNI or is this just as efficient? Any help would be appreciated.

    You seem to be confused...
    "execute a dll using java"
    Unless I'm mistaken, a dll is not executable. A dll is a library of code. This code has (hopefully) some well-defined entry points (declared in a header file somewhere) which you must call in a C/C++ file. The arguments you pass to the dll will come from java through JNI.
    As far as your understanding of this entire process, it is obviously confused beyond the scope of a simple reply. I recommend you read the examples and ALL of the documentation available here:
    http://java.sun.com/docs/books/tutorial/native1.1/index.html
    When you get the/an example running (or just set up to run) then post your code and comments here for more help.
    Ian

  • Executing shellscripts from java

    Hi All,
    I need some information.Ist possible to excecute shellscripts from java?thanks in advance.

    You can execute appropriate shell ("cmd" on windows etc) and pass scrip as a parameter to the shell.

  • Urg:Executing SQL From Java App using Jdbc Driver

    Hi
    I am using JDBC Driver version 9.0.1.1.0.
    I am running this in Thin Client Mode
    My Code Snippet Looks Like This:=
    ==========================================================
    String url = "jdbc:oracle:thin:@localhost:1521:VpDb";
    String userName = "scott";
    String password = "tiger";
    Connection conn = null ;
    Statement st = null ;
    ResultSet rs = null ;
    String categoryCode="ABC";
    try
    conn = DriverManager.getConnection (url, userName, password);
    st = conn.createStatement ();
    String sqlStatement = "Select Count(*) From News Where CategoryCode=" +"\'" + categoryCode + "\'" + ";";
    System.out.println(sqlStatement);
    rs = st.executeQuery ( sqlStatement );
    if( rs.next() )
    System.out.println("Headline Exists");
    else
    System.out.println("No Headline Exists");
    catch (SQLException e )
    System.out.println();
    System.out.println (" SQL ERROR IN IS_NEWS_EMPTY: " + e) ;
    =========================================================
    I have added the classes12.zip and nls_charset12.zip in the classpath.
    Now when i run this it gives me an error saying the following error message:-
    SQL ERROR IN IS_NEWS_EMPTY: java.sql.SQLException: ORA-00911: invalid character
    Can anyone help me with this as to whats going wrong because the exact equivalent of my sqlStamenet runs on SQL command line but not from java code.Why??
    Any Help appreciated
    Thanks
    Mum

    I think it is complaining about the ";" that you add at the end of your string. You don't need to add that to the query.

  • End-of-communication channel while executing sqlldr from java procedure

    Hi all,
    I am having 10g 10.1.0.3.1 ( Infrastructure ) on linux, I am executing Sql Loader
    ( sqlldr ) from client (XP) using java stored procedure. After loading the data I am getting Error - ( end-of-communication channel). But same java procedure is working fine without any error on 10g without (Infrastructure). Is this problem is becuase of infrastructure or some patch has to be installed on the database. For my satisfaction I reinstalled java Virtual Machine on database with the help of
    ( initjvm.sql ). But problem is still there. Any idea what exactly the problem is.
    SKM

    This is the most frequently asked question from Oracle developers.. Never mind putting some light on this error, I want to put it alight! ;-)
    First thing. It is not The Error. It is a sympton of an error.
    This message does not come from the database. It comes from the client OCI (of JDBC) drivers - which suddenly discovered that the Oracle connection (usually a TCP socket connection) has been torn down at the server side. It attempts to write to that socket, only to find that the other party has hung up.
    Why has the other party hung up? That party is either a Dedicated Server Process or a Dispatcher Process. If a dedicated server dies (crashes), it will take its socket handles with it to The Great Recycle Bin In The Sky. If you was serviced by a shared server and it died, the Dispatcher (who handles the TCP comms for it), will automatically close that shared server's connection.
    Usually when a process dies on the Oracle server, it leaves behind an error in the alert log, and trace files. That is where you will find the inklings of what The Error was that caused your client to get the EOF on comms channel message.

  • Executing genstat from java

    hi all
    Sorry if my posting appears to b silly...All i want to do is to execute the statistial s/w GENSTAT from an applet after user is allowed to select data file and procedure file. Is this possible to do in java?? PLease help me out. I have to finish this work TODAY!!!!!
    Thanx
    Bharthi

    Hi Bharthi,
    I have tried something. I do not know it will directly help you. There is a class called Runtime in the APi's of which there is a method exec().
    You can write any command which you write on the console. This method will execute the same. What i have done is i created a simple java file Test and kept it in c:\downloads directory. My aim was to compile the same thru a program..i.e Bharthi.
    Just compile the same after creating a java file and then run Bharthi. This program will compile the Test program at c:\downloads.
    I hope you got the basic logic. Tell me if you could get thru.
    Bye
    Tushar
    import java.lang.Runtime.*;
    public class Bharthi
    public static void main(String[] args)
    try
    Runtime R1= Runtime.getRuntime();
    String filepath="javac c:\\Downloads\\Test.java";
    System.out.println("filepath : = " + filepath);
    Process p1= R1.exec(filepath);
    catch(Exception e)

  • Executing sqlldr from java

    Hi
    I try running the program in command prompt its working ,but when i try run from my java application its not working .
    I am trying to run the code
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.Scanner;
    class Test2
    public static void main(String cmd[]) {
    String str = "";
    System.out.println("Enter command ");
    Scanner sc = new Scanner (System.in);
    String a=sc.next();
    try {
    System.out.println("\nEntering runBCP() ......");
    Process process_bcp = Runtime.getRuntime().exec(a);
    process_bcp.waitFor();
    int returnValue = process_bcp.exitValue();
    System.out.println("\nin runBCP(), returnValue = " +returnValue);
    if(returnValue != 0) {
    InputStream in = process_bcp.getInputStream();
    InputStreamReader preader = new InputStreamReader(in);
    BufferedReader breader= new BufferedReader(preader);
    String msg = null;
    while((msg = breader.readLine()) != null) {
    System.out.println(msg);
    str += "" + msg + "";
    System.out.flush();
    preader.close();
    breader.close();
    in.close();
    InputStream inError = process_bcp.getErrorStream();
    InputStreamReader preaderError = new InputStreamReader(inError);
    BufferedReader breaderError= new BufferedReader(preaderError);
    String errorMsg = null;
    while((errorMsg = breaderError.readLine()) != null) {
    System.out.println("Copy Error: " + errorMsg);
    str += "" + errorMsg + "";
    System.out.flush();
    preaderError.close();
    breaderError.close();
    inError.close();
    else{
    InputStream in = process_bcp.getInputStream();
    InputStreamReader preader = new InputStreamReader(in);
    BufferedReader breader= new BufferedReader(preader);
    String msg = null;
    while((msg = breader.readLine()) != null) {
    System.out.println(msg);
    str += "" + msg + "";
    System.out.flush();
    preader.close();
    breader.close();
    in.close();
    process_bcp.destroy();
    System.out.println("IMPORT PORTFOLIO DATA DONE");
    }catch(InterruptedException e){
    System.out.println("Exception : " + e.toString());
    e.printStackTrace();
    str = "UPLOAD FAILED";
    }catch(Exception e){
    str = "UPLOAD FAILED";
    System.out.println("Exception : " + e.toString());
    e.printStackTrace();
    System.out.println(str);
    when i enter by
    sqlldr userid=System/Violet415 control=loader1.ctl log=loader.log
    nothing comes up . Can you please tell me where to control file and data file in eclipse .
    loader1.ctl(control file)
    load data
    INFILE 'loader2.dat'
    INTO TABLE uel
    TRUNCATE
    FIELDS TERMINATED BY ','
    (article_id SEQUENCE (MAX,1),
    author CHAR(30),
    format,
    pub_date SYSDATE,
    title,
    ext_fname FILLER CHAR(80),
    text LOBFILE(ext_fname) TERMINATED BY EOF)
    please can any body help me in this regards . Thank you in advance
    Edited by: user11357554 on 21-May-2011 09:36
    Edited by: user11357554 on 21-May-2011 09:57

    thank you for your reply .can you please tell is there is any wrong in code.Thank you

  • Cannot call the execute command from java code

    Hello,
    I like to add a new user via a java web service.
    Establishing a connection to the OC4J MBean server is no problem. I also can execute the commands 'listAllCommands' and 'help' on the MBean. But if i try to call the execute command, i always get an NoSuchMethodException. Looking at the MBeanInfos 'execute' is listed there as an operation.
    Can anyone explain this to me?

    Hi,
    I basically used the code described at http://download.oracle.com/docs/cd/B32110_01/web.1013/b28952/mbeans.htm#CIHFDJBJ to connect to the MBeanServer.
    To invoke 'execute' i used
    MBeanServerConnection con= jmxCon.getMBeanServerConnection();
    con.invoke(new ObjectName(MBEAN_NAME), "execute", new Object[] { COMMAND }, new String[] {});
    where MBEAN_NAME is the ObjectName of the CommandService MBean and COMMAND is a String like "identity add ..."

  • How to create a executable file from .java file?

    Well usually we would compile and run our program using jdk1.x. Can we create a .exe file so that it will run everytime I open it without compile and run it?
    Regards,
    Ng

    hai,
    you can create a batch file,in it define the commands javac and java.so that whenever u are running the batchfile it is compiled and the program is executed..
    it will work..
    bye,
    j.mouli

  • Executing jad from java

    Hi, I made this little program :
    private void decompile(String file) {
         File dir = new File(file);
         File[] files = dir.listFiles();
         for (int i = 0; i < files.length; i++) {
              File x = files;
              if (x.getName().endsWith(".class")) {
                   Runtime rt = Runtime.getRuntime() ;
                   try {
                        String cmd = "jad.exe " + file + "\\" + x.getName();
                        Process p = rt.exec(cmd);
                        p.waitFor();
                        p.destroy();
                   } catch (IOException e) {
                        e.printStackTrace();
                   } catch (InterruptedException e) {
                        e.printStackTrace();
              } else if (x.isDirectory()) {
                   decompile(x.getPath());
    but when i execute this in eclipse it hangs at the line
    p.waitFor();
    anyone got an idea ?

    Ok, I tried this :
    private void decompile(String file) {
              FileOutputStream fos = null;
              try {
                   fos = new FileOutputStream("C:\\MyJad.log");
              } catch (FileNotFoundException e1) {
                   e1.printStackTrace();
              File dir = new File(file);
              //System.out.println(dir);
              File[] files = dir.listFiles();
              for (int i = 0; i < files.length; i++) {
                   File x = files;
                   //System.out.println(x.getName());
                   if (x.getName().endsWith(".class")) {
                        //System.out.println(x.getName());
                        Runtime rt = Runtime.getRuntime();
                        try {
                             String cmd = "jad.exe " + file + "\\" + x.getName();
                             System.out.println(cmd);
                             Process p = rt.exec(cmd);
                             StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), "ERROR");
                             // any output?
                             StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), "OUTPUT", fos);
                             // kick them off
                             errorGobbler.start();
                             outputGobbler.start();
                             int exitVal = p.waitFor();
              System.out.println("ExitValue: " + exitVal);
              fos.flush();
              fos.close();
                        } catch (IOException e) {
                             e.printStackTrace();
                        } catch (InterruptedException e) {
                             e.printStackTrace();
                   } else if (x.isDirectory()) {
                        decompile(x.getPath());
    class StreamGobbler extends Thread {
         InputStream is;
         String type;
         OutputStream os;
         StreamGobbler(InputStream is, String type) {
              this(is, type, null);
         StreamGobbler(InputStream is, String type, OutputStream redirect) {
              this.is = is;
              this.type = type;
              this.os = redirect;
         public void run() {
              try {
                   PrintWriter pw = null;
                   if (os != null)
                        pw = new PrintWriter(os);
                   InputStreamReader isr = new InputStreamReader(is);
                   BufferedReader br = new BufferedReader(isr);
                   String line = null;
                   while ((line = br.readLine()) != null) {
                        if (pw != null)
                             pw.println(line);
                        System.out.println(type + ">" + line);
                   if (pw != null)
                        pw.flush();
              } catch (IOException ioe) {
                   ioe.printStackTrace();
    but it still hangs...

  • How to create and execute PL/SQL program or Procedure from Java (JDBC)

    hi all,
    user will enter the Pl/Sql program from User-Interface. that program has to be create in DB and execute that.
    due to some confusions, how to execute this from Java, i (user) entered the same logic through a Procedure.
    my Java code is
    Statement st = con.createStatement();
    Statement.execute(procedure_query); // procedure name is myPro
    CallableStatement cs = con.prepareCall("{call myPro}");
    (as given in SUN docs - http://java.sun.com/docs/books/tutorial/jdbc/basics/sql.html)
    but its not creating the procedure.
    and i tried to run a procedure (which is already created) with CallableStatement, and this is also not working.
    how to get this.
    thanks and regards
    pavan

    Hi,
    SInce the PL/SQL block is keyed in dynamically, you probably want to use the anonymous PL/SQL syntax for invoking it:
    // begin ? := func (?, ?); end; -- a result is returned to a variable
    CallableStatement cstmt3 =
    conn.prepareCall(“begin ? := func3(?, ?); end;”);
    // begin proc(?, ?); end; -- Does not return a result
    CallableStatement cstmt4 =
    Conn.prepareCall(“begin proc4(?, ?); end;”);
    SQLJ covered in chapter 10, 11, and 12 of my book furnish a more versatile dynamic SQl or PL/SQL mechanisms.
    Kuassi
    - blog http://db360.blogspot.com/
    - book http://db360.blogspot.com/2006/08/oracle-database-programming-using-java_01.html

  • Calling executables from java

    hi guys, I'm looking for a way to calla executable programs from java under unix-like operating systems...
    ..can anyone help me???
    p.s.:I already know a system to make this under windows, but I'm not sure it will work with linux too...

    try {
       Process proc = Runtime.getRuntime().exec(new String[]   {"myprog", "arg1"});
       int res = proc.waitFor();
    catch(IOException e) {
    catch(InterruptedException e) {

Maybe you are looking for

  • Songs that I recently added to my iTunes (not purchased from iTunes store) will not sync with my iPod touch 4th generation. How can I fix this?

    I typically download my music directly from youtube. I have never had any issue when it came to putting it on my ipod touch (4th generation). However, today, I downloaded a couple of songs, added them to my iTunes (11.1.4). When I hit "sync" it said

  • Idisk issues

    so i just downloaded lion and everything is cool and i like it alright. but today i tried to delete something off my mac hd and i suppose they changed the format and it now says idisk.  I click on idisk and it asks me to sign in using my name and pas

  • Remotely access usb western digital 2tb storage connected to airport

    Hi everyone, just wanted get some feedback on this set up, if it is possible, and how to configure the settings properly. I want my Netgear n600 router Version 1 + Airport Express + WD 2tb hard drive to = a personal cloud that I can remotely access.

  • Beginning yet again (?)

    I've only been here a little bit and have only been to the basic forums mostly, but the people that are here and the attitudes they display is the only thing keeping me motivated right now. Great people here. I got a book that was recommended on this

  • Choose new speaker name for AirPlay?

    How can I change the name of the speakers to choose that are listed in the list in iTunes? I have 1. Computer, 2. Airport Extender/Express, 3. My Home Theater, 4. Home Theater. I want to change #4 to another name but can't figure out how to do it. Im