Java Runtime exec() with mysqldump

2017-03-13T04:29:00

I'm a little curious about the behaviour of Runtime's exec() method when I run mysqldump. I'm running the following command:

mysqldump --user=root --hex-blob [database name] -r [path to sql file]

What I'm wondering is, where does Runtime search for the program mysqldump.exe?

I see that some people supply the whole file path to mysqldump.exe when executing it using Runtime. Why is this?

The reason why I'm curious is because I have two scenarios:

  1. On one windows machine, if I open run and type "cmd" it will open a command window with the default location C:/. Running the mysqldump command on this machine works.
  2. On another windows machine, if I open run and type "cmd" it will open a command window with the default location H:/. Running the mysqldump command on this machine fails. Java's Runtime cannot find the file mysqldump.exe.

Is it possible that the two windows machines have different default drives and if I don't supply the full path to mysqldump.exe, the system will look in the default driver?

Thanks in advance!

Copyright License:
Author:「Richard Silvertass」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/42752709/java-runtime-exec-with-mysqldump

About “Java Runtime exec() with mysqldump” questions

I'm a little curious about the behaviour of Runtime's exec() method when I run mysqldump. I'm running the following command: mysqldump --user=root --hex-blob [database name] -r [path to sql file] ...
I want to backup mysql database with java. And I want to launch mysqldump.exe independently on location of mysqldump.exe. To launch mysqldump.exe I need to write full path to it : String execute...
I'm trying to use mysqldump with java to create a dump for my database. I've done the code but the condition if(processCompleted == 0) never happens for some reason that I can not understand. And ...
i have tried with the following code snippet: Process p; String command="mysqldump -u'scmuser' -p'scm$123' --routines db_name > /home/ubuntu/wh_demo_db_reset.sql"; p = Runtime.getRuntime().e...
I am using mysqldump like this: Runtime.getRuntime().exec("mysqldump -u USERNAME -pPASSWORD DBNAME > /path/to/location/backup.sql"); in order to dump it into my local files, my java p...
I want to backup database in mysql 5.6. For this I use this method: public boolean backupDB(String dbName, String dbUserName, String dbPassword, String path) { String executeCmd = "D://my...
I am writing a java app that needs to perform mysql dump, and I am using the runtime.exec, based in the when runtime.exec won't article. The code is below: public int exectuteCommand(){ Runtim...
I am not able to do an mysqldump in xampp, it says "The system can not find the file specified". I'm using the following code: public boolean backupDB(String dbName, String dbUserName, String
How to find the error if the database name not exist in mysql. Database name like demo. I provide this following example code String dumpCommand = "C:/Program Files/MySQL/MySQL Server 5.0/bin/mys...
** The following command works fine when run directly on terminal mysqldump -uabc -pabc1234 --compact --no-create-info -w \"fieldname != 'A'\" dbname tablename -hhostaddress --result-file=/tmp/myf...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.