Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, of course it is possible. Write your batch so that it takes one argument - the dump path.</p> <p>Then select the folder location using JFileChooser and execute the batch file in a Java app. The following code will create a frame with two buttons- one that selects a directory and concats the absolute path to a command string, and the other button executes your batch.</p> <pre><code>public class DBDumpExec { private static final String batchCMD = "myBatch.bat"; public static String directoryChosen = ""; public static void main(String[] args) { final JFrame frame = new JFrame("DB Dump Executor"); frame.setSize(450, 150); Container content = frame.getContentPane(); content.setLayout(new GridLayout(3, 1, 5, 5)); // Display directory label final JLabel directoryLabel = new JLabel(); // Button to open Dialog JButton openDialogButton = new JButton("Open Dialog"); openDialogButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Select target dump directory"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); File myFile; int returnVal = chooser.showOpenDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { myFile = chooser.getSelectedFile(); directoryChosen = myFile.getAbsolutePath(); directoryLabel.setText(directoryChosen + " chosen!"); System.out.println(myFile.getAbsolutePath()); } } }); // Click this button to run the batch JButton executorButton = new JButton("Execute DB"); executorButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // Run batch try { Process process = Runtime.getRuntime().exec( batchCMD + " " + directoryChosen); } catch (IOException e) { e.printStackTrace(); } } }); content.add(openDialogButton); content.add(directoryLabel); content.add(executorButton); frame.setVisible(true); } } </code></pre> <p>Read more about executing commands from <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Runtime.html" rel="nofollow">Runtime</a> Javadoc.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload