Call Java code from C#

I'm stuck on one thing i can't get solved. I have part of code, which is executed from command line like a charm. Works without any problem.

So, i will to try to call this command (same) out from C#.

That's the code i'm run from commandline.

java -Xincgc -Xmx1024m -cp "%APPDATA%.minecraft\bin\minecraft.jar;%APPDATA%.minecraft\bin\lwjgl.jar;%APPDATA%.minecraft\bin\lwjgl_util.jar;%APPDATA%.minecraft\bin\jinput.jar" -Djava.library.path="%APPDATA%.minecraft\bin\natives" net.minecraft.client.Minecraft "NAME"

The part i'm trying to get it in C# looks like:

proc.StartInfo.FileName = "java";
proc.StartInfo.Arguments = "-Xincgc -Xmx1024m -cp \"%APPDATA%\\.minecraft\\bin\\minecraft.jar;%APPDATA%\\.minecraft\\bin\\lwjgl.jar;%APPDATA%\\.minecraft\\bin\\lwjgl_util.jar;%APPDATA%\\.minecraft\\bin\\jinput.jar\" -Djava.library.path=\"%APPDATA%\\.minecraft\\bin\\natives\" net.minecraft.client.Minecraft \"NAME\"";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = false;
proc.Start();

But, nothing happens at all. Is there something i'm doing wrong? Thanks for any help!

Answers


Expand the environment variables in the Arguments using Environment.ExpandEnvironmentVariables.

string args = "-Xincgc -Xmx1024m -cp \"%APPDATA%\\.minecraft\\bin\\minecraft.jar;%APPDATA%\\.minecraft\\bin\\lwjgl.jar;%APPDATA%\\.minecraft\\bin\\lwjgl_util.jar;%APPDATA%\\.minecraft\\bin\\jinput.jar\" -Djava.library.path=\"%APPDATA%\\.minecraft\\bin\\natives\" net.minecraft.client.Minecraft \"NAME\"";
proc.StartInfo.Arguments = Environment.ExpandEnvironmentVariables(args);

BTW - you can use a verbatim string literal to make that argument string more readable.

@"-Xincgc -Xmx1024m -cp ""%APPDATA%\.minecraft\bin\minecraft.jar;%APPDATA%\.minecraft\bin\lwjgl.jar;%APPDATA%\.minecraft\bin\lwjgl_util.jar;%APPDATA%\.minecraft\bin\jinput.jar"" -Djava.library.path=""%APPDATA%\.minecraft\bin\natives"" net.minecraft.client.Minecraft ""NAME""";

Need Your Help

good component to password reminding in joomla

php joomla

I would like to change the default behavior of Joomla's password reminding mechanism. I would like to be provided with checking of the strength of a password and (optionally) with captcha capabilit...

Google Geocoding API returning illegalaccesserror

java google-maps google-api geocoding

I sure hope you can help, I am getting towards the end of my rope. I posted this question yesterday but was quickly down-voted because I referred to what I was doing as Distance Matrix API and it was