我已按照本教程 http://blogs.msdn.com/b/dachou/archive/2010/03/21/run-java-with-jetty-in-windows-azure.aspx 但我得到“找不到文件异常当我运行程序时.我尝试了很多次但它不起作用.现在我只将\app\java添加到workerrole并且我使用了这段代码
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
using Microsoft.WindowsAzure.Storage;
namespace JettyWorkerRole
{
public class WorkerRole : RoleEntryPoint
{
public override void Run()
{
string response = "";
System.IO.StreamReader sr;
// This is a sample worker implementation. Replace with your logic.
Trace.TraceInformation("JettyWorkerRole entry point called", "Information");
string roleRoot = Environment.GetEnvironmentVariable("RoleRoot");
string port = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["HttpIn"].IPEndpoint.Port.ToString();
string address = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["HttpIn"].IPEndpoint.Address.ToString();
Trace.TraceInformation("RADICE " + roleRoot, "Information");
Trace.TraceInformation("PORTA " + port, "Information");
Trace.TraceInformation("INDIRIZZO " + address, "Information");
string jreHome = roleRoot + @"\approot\app\jre7";
Trace.TraceInformation("JAVA 7 " + jreHome, "Information");
Process proc = new Process();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.FileName = String.Format("\"{0}\\bin\\java.exe\"", jreHome);
//proc.StartInfo.Arguments = String.Format("-Djetty.port={0} -Djetty.home=\"{1}\" -jar \"{1}\\start.jar\"", port, jettyHome);
proc.StartInfo.Arguments = String.Format("-version");
proc.EnableRaisingEvents = false;
proc.Start();
sr = proc.StandardOutput;
response = sr.ReadToEnd();
while (true)
{
Thread.Sleep(10000);
Trace.TraceInformation("Working", "Information");
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
return base.OnStart();
}
}
}
但是我总是在 proc.Start() 中找不到 Win32 异常文件。我该如何解决这个问题并使用 Java(和码头)?