Reputation: 213
I'm having an issue with "The System cannot find the file specified"
Here is the part of my code that fails:
var processInfo = new ProcessStartInfo("java", javaParam + " -jar " + jar)
{
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true,
RedirectStandardError = true,
StandardErrorEncoding = Encoding.UTF8,
StandardOutputEncoding = Encoding.UTF8,
WorkingDirectory = _diretory
};
Process = new Process { StartInfo = processInfo };
Process.Start();
In this image. you can see "Arguments" and "WorkingDirectory". my "craftbukkit.jar" is in my working directory. But It can't find it. locals http://bumisworld.eu/locals.png
And here is the error when I run it outside Visual Studio..
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at The_Bukkit_GUI_Project.MinecraftProcess.StartProcess()
at The_Bukkit_GUI_Project.Form1.Start()
at The_Bukkit_GUI_Project.Form1.load_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Telerik.WinControls.RadControl.OnClick(EventArgs e)
at Telerik.WinControls.UI.RadButtonBase.buttonElement_Click(Object sender, EventArgs e)
at Telerik.WinControls.RadItem.OnClick(EventArgs e)
at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
at Telerik.WinControls.UI.RadButtonElement.OnClick(EventArgs e)
at Telerik.WinControls.RadItem.DoClick(EventArgs e)
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
But for some reason. This works on my local computer. But this happens on my remote server. And I have no idea why.. So I'm looking for a little help..
Upvotes: 0
Views: 3457
Reputation: 22421
First make sure that Java has been installed on the server. Then you should check the following:
If you start a process, it looks for the file name both in the working directory and in the directories listed in the PATH
environment variable. Chances are good that on your developer machine the Java-directory has been added to the PATH
variable for convinience.
Instead of assigning just java
as the executable path, a more stable way is to provide the full path of the executable you want to start.
A - less clean - way to fix this quickly is to change the PATH
variable on the server so that the Java-directory is also contained. Nevertheless I'd propose to reference the executable by its full path so that you don't have to change the PATH
variable on each computer you want to run your program on.
Upvotes: 1