Question

I am making a portable minecraft that works completely off a flash drive, including java. At my home computer the .bat file works perfectly, however on the school computer it does not run and gives me "java is not recognized as an internal or external command, operable program, or batch file" leading me to believe that the batch is looking for java on the local computer as apposed to my intentions of using the java portable installed on the flash drive.

Here is my code.

@echo off
Title Do not close this window
set APPDATA=%CD%\mcp_data
set JAVA_HOME=%CD%\mcp_data\Java\bin

java -Xmx3072M -jar "%CD%\mcp_data\launcher\MineCraft.jar"
Was it helpful?

Solution

You never set the PATH variable to include java anywhere. Your home system knows where to find a copy of java (because it's most likely installed on your machine too) but the school system doesn't.

So you can either try and change the path variables on the school computer (which you may or may not have the rights to do, and it leaves a trail they might not like), or you can make your bat file refer to the copy of Java on the flash drive by it's full path name, i.e. %CD%\mcp_data\Java\bin\java.exe or whatever the path of the java executable is.

I recommend using the full path name since it's in a bat file, so the fact that it's longer doesn't really matter.

See below.

@echo off
Title DO NOT CLOSE THIS WINDOW!!! Closing this window will force close MineCraft
set APPDATA=%CD%/mcp_data

"%CD%\mcp_data\Java\bin\java.exe" -Xmx3072m -Dorg.lwjgl.opengl.Display.allowSoftwareOpenGL=true -jar "%CD%\mcp_data\launcher\MineCraft.jar"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top