如何安装并忘记 java 9 模块(在 Windows 上)?

编程入门 行业动态 更新时间:2024-10-27 04:28:22
本文介绍了如何安装并忘记 java 9 模块(在 Windows 上)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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 上)?

本文发布于:2023-10-20 13:03:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1511045.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模块   java   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!