Question

When I copy paste the javaw.exe -arguments to console it works but, when I launch it like this it doesn't work.

string directory = "C:\\Users\\Can\\AppData\\Roaming\\.minecraft";
string java = @"C:\windows\system32\javaw.exe";
string javaLocation = "C:\\Program Files\\Java\\jre7\\bin\\javaw.exe";
string RAM = "1G";
string username = "namehere";
string token = "--session token:"+tokenGenerated;
string version = "1.6.2";
string launch = "-Xmx" + RAM + " -Djava.library.path={0}\\versions\\1.6.2\\1.6.2-natives-7453523379463 -cp {0}\\libraries\\net\\sf\\jopt-simple\\jopt-simple\\4.5\\jopt-simple-4.5.jar;{0}\\libraries\\com\\paulscode\\codecjorbis\\20101023\\codecjorbis-20101023.jar;{0}\\libraries\\com\\paulscode\\codecwav\\20101023\\codecwav-20101023.jar;{0}\\libraries\\com\\paulscode\\libraryjavasound\\20101123\\libraryjavasound-20101123.jar;{0}\\libraries\\com\\paulscode\\librarylwjglopenal\\20100824\\librarylwjglopenal-20100824.jar;{0}\\libraries\\com\\paulscode\\soundsystem\\20120107\\soundsystem-20120107.jar;{0}\\libraries\\argo\\argo\\2.25_fixed\\argo-2.25_fixed.jar;{0}\\libraries\\org\\bouncycastle\\bcprov-jdk15on\\1.47\\bcprov-jdk15on-1.47.jar;{0}\\libraries\\com\\google\\guava\\guava\\14.0\\guava-14.0.jar;{0}\\libraries\\org\\apache\\commons\\commons-lang3\\3.1\\commons-lang3-3.1.jar;{0}\\libraries\\commons-io\\commons-io\\2.4\\commons-io-2.4.jar;{0}\\libraries\\net\\java\\jinput\\jinput\\2.0.5\\jinput-2.0.5.jar;{0}\\libraries\\net\\java\\jutils\\jutils\\1.0.0\\jutils-1.0.0.jar;{0}\\libraries\\com\\google\\code\\gson\\gson\\2.2.2\\gson-2.2.2.jar;{0}\\libraries\\org\\lwjgl\\lwjgl\\lwjgl\\2.9.0\\lwjgl-2.9.0.jar;{0}\\libraries\\org\\lwjgl\\lwjgl\\lwjgl_util\\2.9.0\\lwjgl_util-2.9.0.jar;{0}\\versions\\1.6.2\\1.6.2.jar net.minecraft.client.main.Main --username " + username + " " + token + " --version " + version + " --gameDir {0} --assetsDir {0}\\assets";
launch = String.Format(launch, directory);
string text = launch;
// WriteAllText creates a file, writes the specified string to the file, 
// and then closes the file.
Directory.SetCurrentDirectory(@"C:\windows\system32\");
Process.Start("javaw.exe",
Path.Combine(launch));

What am I doing wrong?

Was it helpful?

Solution 2

Just use Java's real location instead of "javaw" like "c:\programfiles\Java\jre7\bin\javaw.exe"

OTHER TIPS

Why do you need to call Path.Combine if your whole path is in one string?

Assuming your javaw.exe is actually in C:\windows\system32\, Process.Start("java.exe", launch); should work as intended.

Source - Path on MSDN: http://msdn.microsoft.com/en-us/library/system.io.path.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top