Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure Visual Studio(2012)工具无法加载java文件未找到异常_Java_Azure_Jetty - Fatal编程技术网

Azure Visual Studio(2012)工具无法加载java文件未找到异常

Azure Visual Studio(2012)工具无法加载java文件未找到异常,java,azure,jetty,Java,Azure,Jetty,我遵循了这个教程 但当我运行程序时,我得到了“未找到文件”异常。 我试了很多次,但都不起作用。 现在,我只在workerrole中添加了\app\java,并使用了以下代码 using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net; using System.Threading; using Microsoft.WindowsAzure

我遵循了这个教程 但当我运行程序时,我得到了“未找到文件”异常。 我试了很多次,但都不起作用。 现在,我只在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(和jetty)?

这是因为默认情况下,宿主操作系统上没有安装JVM/JRE,并且找不到
Java.exe

有几种方法可以将JVM安装到托管的Azure机器上。您引用的博客条目中描述的方法只是执行“复制”“-通过将
jre6
文件夹添加到Azure项目进行安装。但是,请注意,实际的JRE二进制文件没有包含在示例项目中,需要手动添加,并附带正确的部署设置

如中所建议的,另一个选项是将JVM二进制文件放入blob存储,并在角色启动时下载它们