Last Updated
Viewed 14 Times

An Ant BuildException has occured: The following error occurred while executing this line: C:\Polarion\data\workspace\polarion-data\jobs\20191203-1104\sources\ProjektNEU\templates.polarion\CIC\null\build.xml:869: Execute failed: java.io.IOException: Cannot run program "powershell": CreateProcess error=2, The system cannot find the file specified

I tried to run a new build in the Polarion ALM Software, but it throws out this Exception. Does anyone know how to fix this Exception?

I want to get Windows serial number using java code but through exception. My java code is working on some versions of windows (7,8) and not working on windows 10 pro and throws me exception for the same code (not verified on windows vista).

public String getWindowKey() {
    String keydata = "";
    try {
        Process process = Runtime.getRuntime().exec(new String[]{"wmic", "diskdrive", "get", "serialnumber"});
        process.getOutputStream().close();
        BufferedReader input
                = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line;
        String result = "";
        while ((line = input.readLine()) != null) {
            line = line.trim();
            if (line.equalsIgnoreCase("SerialNumber")) {
                continue;
            }
            result += line;
        }
        input.close();
        // String[][] Key = {{"WindowKey", result}};
        keydata = result;
    } catch (Exception ex) {
         LErrorDataLog.info("Exception :" + ex.getMessage());
    }
    return keydata;
}

Something is going wrong with my program for database recovery, this error hides my happiness:

java.io.IOException: Cannot run program "mysql":CreateProcess error=2, The system cannot find the file specified

file to be recovered is located in D:/Backup/backup.sql when I browse and open the file from this path then error appears when I click recovery button. Please help me solve this problem. below is my code with JFileChooser for browsing file location.

browseButton.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent event){

     String recPath = "";
         JFileChooser fc = null;
        if (fc == null) {
            fc = new JFileChooser();
            fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            fc.setAcceptAllFileFilterUsed(false);
    }
    int returnVal = fc.showDialog(null, "Open");
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        recPath = file.getAbsolutePath();

        sourceField.setText(recPath);   


    }

}   

}

);


recoveryButton.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent event){

    try{

        String databaseName ="jdbc:mysql://localhost:3306/myDB";
        String userName     ="abc";
        String password     ="123";
        String source       = sourceField.getText();
        int processComplete;

        String[] executeCmd = new String[]{"mysql",databaseName, "--user=" + userName, "--password=" + password, "-e", "source"+source};

        //sava the command in a array
        Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);// execute the command

        processComplete = runtimeProcess.waitFor();// get the result to variable

        if(processComplete==1){
        JOptionPane.showMessageDialog(null, "Restore Failed");
        }

        else if(processComplete==0){

        JOptionPane.showMessageDialog(null, "Restore Completed");

        }

        }
        catch(Exception ex){

        JOptionPane.showMessageDialog(null,ex); 

        }

        }


}   


);

I'm trying to run a Java program that runs the tskill Windows command, but im getting the exception listed in the title. tskill is on the path when I run it from the command prompt. I'm running this program as a Java Application in Eclipse. I added c:\windows\system32 to the Path in eclipse, but the java program still can't find it. How do I fix this? How can I determine what path is set to in the java program?

    try {
        RunProcess.doExecuteCommand("tskill winword /A");
        Thread.sleep(1000);
    } catch (Throwable t) {
        throw new GenerationException(t);
    }
}
cc