I am running a batch file that
- Opens CMD
- CD to HSQLDB home directory
- Start Database
The database server starts in a CMD window. I have added a Shutdownhook
in my program. Inside it's run method I need to close the server/CMD window. I have tried destroy
method on the Process
object that starts the Server. I think the process instance won't know about the CMD window that was opened by running the bat file. I can't figure out how to do it. I have little or no knowledge about batch files. And I don't know if it is possible using Java all alone.
My command line is quite basic. The content is
START cmd.exe /k "cd C:\Users\aman.jangra\Downloads\hsqldb-2.5.0\hsqldb & java -cp lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:data/mydb --dbname.0 Test"
The cmd window starts the database server in the same window. It can be manually closed i.e. server can be manually closed by pressing Ctrl+C or closing the window but I want to do it when my program exits.