[英]Azure Visual Studio (2012) Tools unable to load java file not found exception
我已按照本教程http://blogs.msdn.com/b/dachou/archive/2010/03/21/run-java-with-jetty-in-windows-azure.aspx的操作,但出現“找不到文件異常當我運行該程序時,我嘗試了很多次,但是沒有用,現在我只向workerrole添加了\\ app \\ java,並且使用了這段代碼
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()上找不到alwais Win32異常文件。 如何解決此問題並使用Java(和碼頭)?
這是因為默認情況下, 托管操作系統上未安裝JVM / JRE ,並且未找到java.exe
。
有幾種方法可以在托管的Azure計算機上安裝JVM。 您引用的博客文章中描述的內容只是通過將jre6
文件夾添加到Azure項目中來執行“復制”安裝。 但是,請注意,實際的JRE二進制文件未包含在示例項目中,需要手動添加,以及正確的部署設置。
如該MSDN博客中所建議,另一種選擇是將JVM二進制文件放入blob存儲中,並在角色啟動時將其下載。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.