C#/Java: Can't launch JAR from C# + Exception log

Started by
4 comments, last by Drakken255 11 years, 7 months ago
Hello all,

I am trying to manually start the minecraft.jar with the needed username and session ID, and I receive a java exception.

Code:


ProcessStartInfo mcStartInfo = new ProcessStartInfo("java", "-Xms1024m -Xmx1024m -cp \"" + appData + "\\.minecraft\\bin\\minecraft.jar; " + appData + "\\.minecraft\\bin\\jinput.jar; " + appData + "\\.minecraft\\bin\\lwjgl.jar; " + appData + "\\.minecraft\\bin\\lwjgl_util.jar\" -Djava.library.path=\"" + appData + "\\.minecraft\\bin\\natives\" net.minecraft.client.Minecraft" + " " + username + " " + sessionID);


The exception is close to the following (I can't copy/paste, but rather retype):

Exception in thread "main" java.lang.NoClassefFoundError: org/lwjgl/LWJGLException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
at java.net.URLClassoader$1.run (Unknown Source)
at java.net.URLClassoader$1.run (Unknown Source)
at java.security.AccessController.doPriviledged (Native Method)
at java.net.URLClassLoader.findClass (Unknown Source)
at java.lang.ClassLoader.loadClass (Unknown Source)
at java.misc.Launcher$AppClassLoader.loadClass (Unknown Source)
at java.lang.ClassLoader.loadClass (Unknown Source)
... 6 more
Advertisement
Try to remove the spaces in the classpath
[source lang="java"]"\\.minecraft\\bin\\minecraft.jar; " => "\\.minecraft\\bin\\minecraft.jar;"[/source]

and add an space after the last class path entry
[source lang="java"]"\\.minecraft\\bin\\lwjgl_util.jar\" => "\\.minecraft\\bin\\lwjgl_util.jar \"[/source]
Holy goodness, it works!!1! Thanx!!!
Now the real problem is that I can't seem to start Minecraft at 1024m or above. Only at 512 or below. Why is that, especially when I have 32g of ram?

Now the real problem is that I can't seem to start Minecraft at 1024m or above. Only at 512 or below. Why is that, especially when I have 32g of ram?

Holy crap, 32GB! Umm, do you have 64-bit Java? The 32-bit one is limited to 2048MB of heap and MC might be doing some behind-the-scenes allocation. Does the JVM say anything when you try with 1024MB or does it like... not start?

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Java allows me to start both a legit Minecraft client and a server at 8GB each and at the same time, so I'm easily assuming I have 64-bit. When my program tries to start the process, a message box pops up with something like "Could not start Java Virtual Machine. Fatal exception occurred. Java will now exit."

EDIT: It will now work at 1024m, but not at 2048m.

EDIT 2: Also, Minecraft starts with the java icon. I tried the following to change it, but it doesn't work:


//Class level:
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hwnd, int message, int wParam, IntPtr lParam);
private const int WM_SETICON = 0x80;
private const int ICON_SMALL = 0;
private const int ICON_BIG = 1;

//Method level:
minecraft.Start();
minecraft.WaitForInputIdle();
SendMessage(minecraft.MainWindowHandle, WM_SETICON, ICON_BIG, Icon.FromHandle(this.Handle).Handle);

//Also tried:
//SendMessage(minecraft.MainWindowHandle, WM_SETICON, ICON_SMALL, Icon.FromHandle(this.Handle).Handle);

This topic is closed to new replies.

Advertisement