在不改变环境变量的情况下编程 Minecraft Mods? [英] Program Minecraft Mods without Changing Environment Variables?

查看:68
本文介绍了在不改变环境变量的情况下编程 Minecraft Mods?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Forge 对 Minecraft 模组进行编程.我正在通过标准安装开始创建 mod,但我遇到了一个问题.我运行了代码gradlew setupDecompWorkspace eclipse",它告诉我ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.请在你的环境中设置 JAVA_Home 变量以匹配你的 Java 安装位置."是否有可能更改其他内容或做其他事情以允许我进行编程?我也无法更改环境变量.

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.

推荐答案

即使不是管理员,您也可以更改环境变量.

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

最简单的解决方案是使用 set 临时更改您的会话的环境变量(IE,当您关闭命令提示符时,它将被重置):

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

显然,如果您将 JDK 放在不同的位置,您需要将指定的位置更改为不同的位置.

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

如果您想更永久地更改它,您可以使用 setx 命令.Setx 会保留您在会话之间所做的更改(更重要的是,您无需成为管理员,因为更改只会对您的帐户进行).请注意,运行 setx 不会将更改应用于当前 命令提示符窗口,只会应用于未来的;设置路径后,您需要关闭并重新打开命令提示符.

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.

运行

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

然后关闭并重新打开命令提示符,它应该保持路径设置.(再次注意,您需要使用 Java 安装路径;这里也需要用引号将其括起来).

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).

如果你不想每次都运行set,你可以编辑gradlew.bat并将相同的set命令放在顶部.

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.

只需用文本编辑器打开gradlew.bat,然后放入

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).

这篇关于在不改变环境变量的情况下编程 Minecraft Mods?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆