Java 9 引入了模块,这是对不存在的问题的可怕修复.搜索谷歌如何安装 java 模块"并没有带来任何有用的东西.
Java 9 introduced modules, which was a horrible fix for a non-existing problem. Searching google "How to install java modules" doesn't bring up anything useful.
现在,在我屈服于诱惑并将整个 JDK 和 JavaFX 重新打包到一个 jar 文件中,并将其添加到类路径(假设仍然有效)之前,谁能帮我撤消这些白痴所做的事情?
Now, before I give in to the temptation and repackage the whole JDK and JavaFX into a single jar file, and add it to the classpath (assuming that still works), can anyone help me with undoing what these idiots did?
我想要的是任何 jar 以java -jar *.jar"运行.没有--module-path,没有--add-modules.
What I want is for any jar to run with "java -jar *.jar". Without --module-path, without --add-modules.
第一部分看起来很简单,将所有 jmods 复制到 JDK/jmods 应该可以工作,但之后我需要一种方法来告诉 java 运行时始终加载所有模块.
The first part seems easy, copying all jmods into JDK/jmods should work, but after that I need a way to tell the java runtime to always load all modules.
(不,我不想学习如何正确"使用模块,我想要一种安装它们并忘记它们的方法.)
(And no, I don't want to learn how to "properly" use modules, I want a way to install them and forget about them.)
推荐答案绝对没有必要做任何你考虑过的事情.如果你不想要模块(像我一样),那就不要使用它们.您甚至可以运行非常大的 JavaFX 应用程序,甚至无需考虑模块.只需执行以下操作.像往常一样将所有依赖项放在类路径上(还有 JavaFX jars).然后向您的程序添加一个单独的启动器,如下所示:
There is absolutely no need to do anything of what you considered to too. If you don't want modules (like me) then just don't use them. You can run even very big JavaFX applications without even thinking about modules. Just do the following. Put all dependencies on your classpath as usual (also the JavaFX jars). Then add a separate launcher to your program like this:
public class MyApp extends Application { <rest of the JavaFX code deleted> } class MyAppLauncher {public static void main(String[] args) {MyApp.main(args);}}现在调用这个启动器而不是你真正的主,你就完成了.
Now call this launcher instead of your real main and you are done.
更多推荐
如何安装并忘记 java 9 模块(在 Windows 上)?
发布评论