Results 1 to 2 of 2
  1. #1
    danielleon11 is offline Member
    Join Date
    Jul 2010
    Posts
    1
    Rep Power
    0

    Smile execute a .exe with attributes from java

    Hello, to transfer a CSV file from a Mysql Server to a client I run the following command in cmd:

    C:\path_where_mysql_is\mysql --user=root --host=localhost --password=mypass --database=mydb --execute="select * from table;" > C:\some_output_file.txt

    How can I run this command from java.... I read that Runtime.getRuntime().exec() can help me but I really don't know.. Thanks

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    Have a look at the new ProcessBuilder here

    Where you can set up an array of the command line parameters and pass it into the exec(String[] cmdarray).

    Perhaps use a List<String> to build up the parameters too then call toArray when passing it into ProcessBuilder.exec().

Similar Threads

  1. time to execute a java app
    By svpranay in forum New To Java
    Replies: 6
    Last Post: 06-23-2010, 08:06 AM
  2. Replies: 9
    Last Post: 11-19-2009, 04:31 PM
  3. how to execute an executable using java
    By kala143 in forum Java 2D
    Replies: 4
    Last Post: 09-26-2008, 03:10 PM
  4. Replies: 2
    Last Post: 12-04-2007, 10:49 AM
  5. Execute a new program in java
    By mathias in forum Advanced Java
    Replies: 1
    Last Post: 07-31-2007, 05:42 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •