Program Minecraft Mods without Changing Environment Variables?

别来无恙 提交于 2021-02-11 02:26:34

问题


I am wanting to program Minecraft mods using forge. I am going through the standard installation to begin creating mods, but I have run into an issue. I ran the code "gradlew setupDecompWorkspace eclipse" and it is telling me "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_Home vairable in your environment to match the location of your Java installation." Is it possible to change something else or do something else that will allow me to program? I also cant change the environment variables.


回答1:


You can change environment variables, even without being an administrator.

The easiest solution is to use set to temporarily change the environment variable for only your session (IE, it'll get reset when you close your command prompt):

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_91
gradlew setupDecompWorkspace eclipse

Obviously, you'd change the location given to a different one if you have the JDK in a different location.

If you want to change it more permanently, you can use the setx command. Setx keeps the changes you made between sessions (and, more importantly, you don't need to be an administrator, since changes are only made to your account). Note that running setx doesn't apply the changes to the current command prompt window, only future ones; you'd need to close and reopen command prompt after setting the path.

Run

setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0_91"

and then close and reopen your command prompt, and it should keep the path set. (Note that again, you'd want to use the path for your java installation; also it needs to be surrounded by quotes here).


If you don't want to run set each time, you can probably edit gradlew.bat and put the same set command at the top of it.

Simply open gradlew.bat with a text editor and then put

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_91

at the top of it (again, replace the path with the correct one for your version).



来源:https://stackoverflow.com/questions/36869464/program-minecraft-mods-without-changing-environment-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!