I am using a C# Application to call a Batch file which compiles and run a java program. (This is a scraper project which grabs content from websites.) The batch file consists of following command:
java -classpath core.jar;mysql.jar;realtouch.jar; com.parser.MainClass C:/wamp/www/C21_real2/properties http://www.realestate.com.au/realestate/agent/century+21+harbourside+neutral+bay/tzrjnd
This batch file is working fine,when i go to the folder and double click on the batch file. But when i am calling this run file through my application using System.Diagnostics.Process
, it says:
Could not find the main class com.parser.MainClass. Program will exit now.
And command window will exit within seconds.
I am calling the program from C# as follows:
Process batch = new Process();
string pathtoRunFile="E:\\newFiles\\run.bat";
batch.StartInfo.FileName = PathtoRunFile;
batch.StartInfo.Arguments = "";
batch.StartInfo.UseShellExecute = true;
batch.Start();
batch.WaitForExit();
Please someone help me ASAP. I am really confused why this is not working when i am calling it from my application. I am not much of a Java developer. So is this a problem with my main Java program? If so how to solve this? What I need is to run the batch file from my C# application.
The structure of the newfiles
folder is as follows: (contains only files)
- core.jar
- mysql.jar
- realtouch.jar
- run.bat