2012-12-12 38 views
-1

我正在研發遊戲啓動器(是的,已經有一個,但我的將不同)。 問題是,如果您登錄,遊戲會嘗試啓動,但我得到一個控制檯窗口,顯示「無法訪問jarfile c:\ users \ max korlaar \ dropbox \ max」,並在1毫秒後關閉。 我不知道爲什麼,因爲我的Process Arguments中給出的jar文件存在,我認爲VB.net會對該位置進行一些操作。 jar文件位於相對於我的程序的文件夾Bin中。 (是的,我試着用&替換+)無法打開Jar文件,使用正確的參數VB

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() 

嘗試一些建議,我修改了一些後,並得到了這一點:

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() 

但現在我得到的錯誤:無法訪問jar文件「{minecraft.jar的路徑(正確路徑)}」 有誰知道爲什麼?以及如何解決這個錯誤?

+0

*「煤礦將是不同的」 *除此之外,還有什麼其他區別有哪些? –

+0

您是否嘗試使用您在應用程序中使用的相同命令從應用程序路徑的命令窗口啓動「jar」文件? – sloth

+0

是的,問題是我在jar文件路徑之前和之後添加了一個'。但是現在我從Class中找到了一個很長的錯誤,或者類似的東西 - 也許某個具有Minecraft經驗的人知道 – MaxKorlaar

回答

1

你的路徑中有空間,所以你必須引用它(放在兩個"之間)。

Dim args As String = "-jar -natives""{1}"" -lwjgl""{2}"" ...etc..etc..." 

否則,java可執行文件將無法正確區分傳遞給它的參數。


如果你的路徑是c:\users\max korlaar\dropbox\max & alex,你不引用它,將它傳遞給Java executale作爲

java -jar c:\users\max korlaar\dropbox\max & alex

只有c:\users\max korlaar\dropbox\max將被用來作爲參數來java -jar

因此,你必須使用引號:從事實你不工作

java -jar "c:\users\max korlaar\dropbox\max & alex"

+0

是的,但問題是,該文件與我的程序有關。該文件位於我的程序的位置,位於我的程序旁邊的文件夾中。那麼我應該怎麼做?我已經在每個{#}之後放置了「」。 – MaxKorlaar

+0

現在我已更改我的代碼,但出現錯誤:無法訪問jarfile {正確的路徑到minecraft.jar}。 (也在一個快速消失的控制檯窗口中(請參閱代碼更改問題) – MaxKorlaar

+0

回答此問題。謝謝。現在我有另一個問題,但我會問另一個問題 – MaxKorlaar