I wrote a very small function to run a Java application in C # NET, but I get the error "An object reference is required for a non-static field, method or property" MinecraftDaemon.Program.LaunchMinecraft () 'C: \ Users \ Mike \ Desktop \ Minecraft \ MinecraftDaemon \ Program.cs ". I was looking for other topics that suffer from the same problem, but I don’t understand what this means or why I get it.
namespace MinecraftDaemon
{
class Program
{
public void LaunchMinecraft()
{
ProcessStartInfo processInfo = new ProcessStartInfo("java.exe", "-Xmx1024M -Xms1024M -jar minecraft_server.jar nogui");
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
try
{
using (Process minecraftProcess = Process.Start(processInfo))
{
minecraftProcess.WaitForExit();
}
}
catch
{
}
}
static void Main(string[] args)
{
LaunchMinecraft();
}
}
}
source
share