Search code examples
javacmdminecraftargs

Run exe from Java args (Minecraft Launcher)


I'm hoping to launch another application when Minecraft runs from the MC launcher so the second application doesn't need to be opened or run manually. I'm thinking the Java args could be a way to do this. Is this feasible?

For reference, this is the default java args:

"-Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M"

Is there a flag that would allow me to run an exe or execute a shell command?


Solution

  • When using the old Minecraft launcher (install guide), you can replace the launcher.jar file in your %APPDATA%/Roaming/.minecraft directory with your own custom Java application. Within your own application, you can do anything you like. To start Minecraft, you will have to start the original launcher.jar yourself. This can be done through Runtime.exec(String[]), or by including the launcher.jar file as a dependency in your project and calling its main(String[]) method directly. Alternatively, you could write a batch script that starts both the Minecraft launcher and your application, or you could write a Minecraft Forge client mod in which you can do anything as soon as the game starts.