I am a newbie in Java programming. I have this class which should run a .bat file located on a folder in my Local Disk:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Execute {
public static void main(String args[])
{
String stream = null;
try {
Process p = Runtime.getRuntime().exec(
"C:\\WINDOWS\\system32\\cmd.exe /c start C:\\Identify\\dll\\StartSample.bat");
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:");
while ((stream = stdInput.readLine()) != null)
{
System.out.println(stream);
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):");
while ((stream = stdError.readLine()) != null)
{
System.out.println(stream);
}
System.out.println("ended!!");
System.exit(0);
}
catch (IOException e)
{
System.out.println("exception happened: ");
System.err.println(e.getMessage());
System.exit(-1);
}
}
}
Whenever I run the .bat file, it works just as it should. However, when I run the class that I made, the command prompt displays "C:\palmuswebservice>java Error: Could not find or load main class"
I don't know what seems to be wrong. Can someone help me on how I can fix this?