I just want a query to run from java using run command
SQL Server should come with a command line utility that lets you run queries against the database. Hopefully that utility will also let you specify that the output should be to a CSV file. Once you figure out the proper query syntax, and can run the query from the command line, place the command line with a Runtime.exec() call.
The CSV formatting is probably what will be the hard part; the utility might not have that as an output option. Which means you will have to output to a text file and run a script against the text file. You will have to wrap all of this within a script which you invoke via exec().
Or perhaps there is such a utility that will output the CSV for you...
(Then again, you might actually be asking for the syntax for the command line utility, in which case my response hasn't helped any...)