需要帮助Server Gui给出错误 [英] Need help with Server Gui giving error

查看:68
本文介绍了需要帮助Server Gui给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的我的Minecraft服务器制作一个GUI到目前为止我得到它显示输出但是我发现错误说

I am trying to make a GUI for my minecraft server so far i got it to display the output but i come to an error saying

'java' is not recognized as an internal or external command,
operable program or batch file.



我不明白这是因为在另一个程序中我使编码是如此的类似它应该工作,但它不会?有人能帮我吗?提前谢谢




I do not understand this because in another program i made the coding is so simular it should work but it wont? Can someone help me? Thank you in advance

using System;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using Novus_Gui.Properties;

namespace Novus_Gui
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public void button1_Click(object sender, EventArgs e)
        {

            Process ServerProcess = new Process();
            ServerProcess.StartInfo.UseShellExecute = false;
            ServerProcess.StartInfo.FileName = "CMD.exe";
            ServerProcess.StartInfo.Arguments = "/c java -jar Server.jar";
            ServerProcess.StartInfo.CreateNoWindow = true;
            ServerProcess.StartInfo.ErrorDialog = false;
            ServerProcess.StartInfo.RedirectStandardError = true;
            ServerProcess.StartInfo.RedirectStandardOutput = true;
            ServerProcess.StartInfo.RedirectStandardInput = true;
            ServerProcess.Start();
            StreamWriter inputWriter = ServerProcess.StandardInput;
            StreamReader outputReader = ServerProcess.StandardOutput;
            StreamReader errorReader = ServerProcess.StandardError;
            ServerProcess.WaitForExit();
            //Display Outputs
            string displayText = "Output" + Environment.NewLine + "==============" + Environment.NewLine;
            displayText += outputReader.ReadToEnd();
            displayText += Environment.NewLine + "Error" + Environment.NewLine + "==============" +
                           Environment.NewLine;
            displayText += errorReader.ReadToEnd();
            richTextBox1.Text = displayText;
        } 
    }
}

推荐答案

请尝试以下方法:

Try the following:
...
            ServerProcess.StartInfo.FileName = @"c:\Program Files\Java\jre8\bin\java.exe"; // put your own path here
            ServerProcess.StartInfo.Arguments = "-jar Server.jar";
...


要么像Mehdi所说,要么将路径放到系统路径中(这通常是作为jre install)..检查它在路径中,调出一个命令/ dos提示符,然后键入



java -version



如果您收到错误路径不正确



''g''
Either as Mehdi says, or, put the path to java in your system path (this is usually done as part of the jre install) .. to check that its in the path, bring up a command/dos prompt, and type

java -version

if you get an error the path is incorrect

''g''


这篇关于需要帮助Server Gui给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆