'java' is not recognized as an internal or external command, operable program or batch file.
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; } } }
... ServerProcess.StartInfo.FileName = @"c:\Program Files\Java\jre8\bin\java.exe"; // put your own path here ServerProcess.StartInfo.Arguments = "-jar Server.jar"; ...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)