我正在编写一个应用程序以使用mods启动Minecraft,并且还会使mods保持最新状态。我收到的JVM错误似乎无法解决。
我一直在Stack Exchange和Stack Overflow上搜索答案,但在Google上找不到任何有用的内容。我实际上是根据我在本网站上发现的另一个问题编写代码,但它遗漏了很多重要信息。
这个错误是由什么引起的?这是我的代码的问题吗?有没有办法解决它?
编辑:是否有可能获得JVM的输出?我需要更多的信息来进行调试。
这是我的VB.NET代码。
Imports System.Net
Imports System.IO
Imports System.Threading
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Public Class Form1
Dim streamReader As StreamReader
Dim Root As String = "C:\Users\admin\AppData\Roaming\.minecraft"
Dim SelectedGameVersion As String = "1.10"
Dim MinecraftJavaPath = "C:\Program Files (x86)\Minecraft\runtime\jre-x64\1.8.0_25\bin\javaw.exe"
Dim JavaPath = "C:\Program Files\Java\jre1.8.0_121\bin\javaw.exe"
Dim FileList As New ArrayList
Dim assets As String = "C:\Users\admin\AppData\Roaming\.minecraft\assets\index\1.10.json"
Dim MinMemAlloc As String = "1G"
Dim MaxMemAlloc As String = "4G"
Dim mainClass As String = "net.minecraft.client.main.Main"
Dim accessToken As String = "INVALID"
Dim id As String = "INVALID"
Dim username As String = "INVALID"
Dim legacy As Boolean = False
Dim debugString As String = ""
Dim LIBRARIES As String = Root + "\versions\1.10.2\1.10.2-natives"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
'debugString = "UUID: " + id + ", Username: " + username + ", Legacy?: " + legacy.ToString
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\java3d\vecmath\1.5.2\vecmath-1.5.2.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\net\sf\trove4j\trove4j\3.0.3\trove4j-3.0.3.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\com\ibm\icu\icu4j-core-mojang\51.2\icu4j-core-mojang-51.2.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\net\sf\jopt-simple\jopt-simple\4.6\jopt-simple-4.6.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\com\paulscode\codecwav\20101023\codecwav-20101023.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\io\netty\netty-all\4.0.23.Final\netty-all-4.0.23.Final.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\com\google\guava\guava\17.0\guava-17.0.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\commons-io\commons-io\2.4\commons-io-2.4.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\com\google\code\gson\gson\2.2.4\gson-2.2.4.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\com\mojang\authlib\1.5.24\authlib-1.5.24.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\com\mojang\realms\1.10.6\realms-1.10.6.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-compress\1.8.1\commons-compress-1.8.1.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\org\apache\httpcomponents\httpclient\4.3.3\httpclient-4.3.3.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-api\2.0-beta9\log4j-api-2.0-beta9.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-core\2.0-beta9\log4j-core-2.0-beta9.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl\2.9.4-nightly-20150209\lwjgl-2.9.4-nightly-20150209.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl_util\2.9.4-nightly-20150209\lwjgl_util-2.9.4-nightly-20150209.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl-platform\2.9.4-nightly-20150209\lwjgl-platform-2.9.4-nightly-20150209-natives-windows.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\net\java\jinput\jinput-platform\2.0.5\jinput-platform-2.0.5-natives-windows.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\tv\twitch\twitch\6.5\twitch-6.5.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\tv\twitch\twitch-platform\6.5\twitch-platform-6.5-natives-windows-64.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\libraries\tv\twitch\twitch-external-platform\4.5\twitch-external-platform-4.5-natives-windows-64.jar;") ' UPDATED
FileList.Add("C:\Users\admin\AppData\Roaming\.minecraft\versions\" + SelectedGameVersion + ".jar;") ' UPDATED
Catch ex As Exception
MsgBox(ex.Message, , "Oh noes!")
End Try
End Sub
Public Sub authRequest()
Try
Dim status As HttpStatusCode = HttpStatusCode.ExpectationFailed
Dim response As Byte() = PostResponse("http://authserver.mojang.com/authenticate", "{""agent"": {""name"": ""Minecraft"",""version"": 1},""username"": " + txtUsername.Text + ",""password"": " + txtPassword.Text + "}", status)
Dim responseString As String
responseString = System.Text.Encoding.UTF8.GetString(response)
responseString = "NULL"
Console.WriteLine("Response Code: " & status)
Console.WriteLine("Response String: " & responseString)
Dim json As String = responseString
Dim ser As JObject = JObject.Parse(json)
Dim data As List(Of JToken) = ser.Children().ToList
For Each item As JProperty In data
item.CreateReader()
Select Case item.Name
Case "availableProfiles"
For Each profileVar As JObject In item.Values
id = profileVar("id")
username = profileVar("name")
legacy = profileVar("legacy")
Next
Case ""
For Each profileVar As Object In item.Values
accessToken = profileVar("accessToken")
'MsgBox(profileVar("accessToken"), , "Debug")
Next
End Select
Next
Catch ex As Exception
MsgBox(ex.Message, , "Oh noes!")
End Try
End Sub
Public Sub launchGame()
Try
If Not File.Exists(Root + "\versions\" + SelectedGameVersion + "\" + SelectedGameVersion + ".jar") Then
MsgBox("File not found: " + SelectedGameVersion + ".jar")
Else
Dim Gamelibraries As String = Nothing
For i = 0 To FileList.Count - 1
Gamelibraries += FileList.Item(i) +
Environment.NewLine()
Next
Dim p As New Process()
p.StartInfo.FileName = JavaPath
p.StartInfo.Arguments = " -Xms" + MinMemAlloc + "M -Xmx" + MaxMemAlloc + "M " +
"-Djava.library.path=" + LIBRARIES + "-natives -cp " +
Gamelibraries.ToString() + mainClass +
" --username=" + username +
" --version " + SelectedGameVersion +
" --gameDir " + Root +
" --assetsDir " + Root + "\assets" +
" --assetIndex 1.10" +
" --accessToken " + accessToken +
" --userProperties {}" +
" --userType mojang" +
" --uuid " + id +
" --nativeLauncherVersion 307"
p.StartInfo.WorkingDirectory = Root
p.StartInfo.CreateNoWindow = False
p.StartInfo.UseShellExecute = False
p.EnableRaisingEvents = True
Application.DoEvents()
p.StartInfo.RedirectStandardError = True
p.StartInfo.RedirectStandardOutput = True
'AddHandler p.ErrorDataReceived, AddressOf p_OutputDataReceived
'AddHandler p.OutputDataReceived, AddressOf p.OutputDataReceived
p.Start()
p.BeginErrorReadLine()
p.BeginOutputReadLine()
'Button1.Text = "Play"
'Button1.Enabled = True
'Button2.Enabled = True
'Button3.Enabled = True
'Button4.Enabled = True
'Button5.Enabled = True
End If
Catch ex As Exception
MsgBox(ex.Message, , "Oh noes!")
End Try
End Sub
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
Try
authRequest()
'Thread.Sleep(3000)
'MsgBox(debugString, , "Debug")
launchGame()
Catch ex As Exception
MsgBox(ex.Message, , "Oh noes!")
End Try
End Sub
Public Function PostResponse(url As String, content As String, ByRef statusCode As HttpStatusCode) As Byte()
Dim responseFromServer As Byte() = Nothing
Dim dataStream As Stream = Nothing
Try
Dim request As WebRequest = WebRequest.Create(url)
request.Timeout = 120000
request.Method = "POST"
Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes(content)
request.ContentType = "application/json"
request.ContentLength = byteArray.Length
dataStream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
dataStream = response.GetResponseStream()
Dim ms As New MemoryStream()
Dim thisRead As Integer = 0
Dim buff As Byte() = New Byte(1023) {}
Do
thisRead = dataStream.Read(buff, 0, buff.Length)
If thisRead = 0 Then
Exit Do
End If
ms.Write(buff, 0, thisRead)
Loop While True
responseFromServer = ms.ToArray()
dataStream.Close()
response.Close()
statusCode = HttpStatusCode.OK
Catch ex As WebException
If ex.Response IsNot Nothing Then
dataStream = ex.Response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim resp As String = reader.ReadToEnd()
statusCode = DirectCast(ex.Response, HttpWebResponse).StatusCode
Else
Dim resp As String = ""
statusCode = HttpStatusCode.ExpectationFailed
End If
Catch ex As Exception
statusCode = HttpStatusCode.ExpectationFailed
End Try
Return responseFromServer
End Function
End Class
注意:我对JSON非常陌生,所以如果你能指出它是否有问题会对我的项目产生很大影响。