开发者

calling java class file through windows service in .net

i have creared windows service from C# for calling java class file. i have used bat file to call this java file in C#. the task of the java class is create output file. but the when stated the service output file wasnt created. java class is worked perfeclty with out servise when it invoke from bat file. (but may task manag开发者_如何学Goer shows instantiates of command prompt.)

is it possible to call java class through bat file in windws servise?


I believe that issue will be probably related to user permissions - windows service typically runs under say Network Service a/c that may not have permissions to write file at many location. So I suggest that you try writing file at location where every user has write permissions (or tinker with folder permissions where you want to write file).


It's a bit of a long way around, but you could use something like iKVM to call the Java class directly from .NET.

http://www.ikvm.net/


I've solved the problem by hard coding my bat file code in program. I also had to specify working directory:

process1.EnableRaisingEvents = false;
//Process p ;

process1.StartInfo.UseShellExecute = false ;
string str = "my parameters";
process1.StartInfo.WorkingDirectory = @"C:\kesara";
//System.Diagnostics.Process.Start(batfilepath,);
process1.StartInfo.FileName = @"C:/j2sdk1.4.2_08/bin/java.exe";
process1.StartInfo.Arguments = str;
process1.Start();
process1.Close();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜