I’m working on a game launcher (Yes there is already one, but mine will be different).
The problem is, if you log in, the game tries to launch, but I get a console window displaying “cannot access jarfile c:\users\max korlaar\dropbox\max ” and it closes after 1 milisecond.
I don’t know why, because the given jar files in my Process Arguments are there, and I think VB.net does something with the location. The jar files are located in a folder Bin, relative to my program. (And Yes, I tried replacing + with &)
Dim process As New Process
Dim info As New ProcessStartInfo
info.FileName = GetJavaHome() + "\java.exe"
info.CreateNoWindow = True
info.UseShellExecute = True
info.RedirectStandardError = False
info.RedirectStandardOutput = False
Dim args As String = "-jar -natives{1} -lwjgl{2} -mlcfg{3} -mlmod{4} -j{5} -u{6} -s{7}"
info.Arguments = String.Format(args, My.Application.Info.DirectoryPath + "\bin\natives", My.Application.Info.DirectoryPath + "\bin\natives", My.Application.Info.DirectoryPath + "\bin\lwjgl.jar", My.Application.Info.DirectoryPath + "\config\", My.Application.Info.DirectoryPath + "\mods\", My.Application.Info.DirectoryPath + "\bin\minecraft.jar\", TextBox1.Text, result)
info.Arguments = info.Arguments.Replace("\bin\minecraft.jar", My.Application.Info.DirectoryPath + "\bin\minecraft.jar")
process.StartInfo = info
process.Start()
After trying some suggestions I modified it a little, and got this:
Dim process As New Process
Dim info As New ProcessStartInfo
info.FileName = GetJavaHome() + "\java.exe"
info.CreateNoWindow = False
info.UseShellExecute = False
info.RedirectStandardError = False
info.RedirectStandardOutput = True
'Got error: Corrupt jar file... Someone with Minecraft Experience can help me to launch it?
Dim args As String = "-jar ""{6}"" -natives ""{1}"" -lwjgl ""{2}"" -mlcfg ""{3}"" -mlmod ""{4}"" -j ""{5}"" -u ""{6}"" -s ""{7}"""
' Got CMD window popping up with error and disappearing
info.Arguments = String.Format(args, "none", My.Application.Info.DirectoryPath & "\bin\natives\", My.Application.Info.DirectoryPath & "\bin\natives", My.Application.Info.DirectoryPath & "\bin\lwjgl.jar", My.Application.Info.DirectoryPath & "\config\", My.Application.Info.DirectoryPath & "\mods\", "'" & Application.StartupPath & "\bin\minecraft.jar'", TextBox1.Text, result)
'info.Arguments = info.Arguments.Replace("\bin\minecraft.jar", My.Application.Info.DirectoryPath + "\bin\minecraft.jar")
process.StartInfo = info
process.Start()
But now I get the error: Unable to access jarfile “{path to minecraft.jar (correct path)}”
Does anyone know why? And how to fix that error?
You have a space in your paths, so you have to quote it (put in between two
").Otherwise, the java executable will not be able to distinguish correctly between the arguments you pass to it.
If your path is
c:\users\max korlaar\dropbox\max & alex, and you don’t quote it, you pass it to the java executale aswhere only
c:\users\max korlaar\dropbox\maxwould be used as an argument to tojava -jar.Hence you have to use quotes: