重构 Java 管理
- 在设置中增加 Java 管理页面,用户可通过该页面安装、添加、查看、禁用或卸载 Java;
- 优化 Java 扫描逻辑;
- 优化 Java 自动选择逻辑;
- 支持用户指定所使用的 Java 版本。
暂未测试,晚点再说。
建议在获取完所有 Java 路径后将结果打印到日志中
在指定了 Java 版本为 8 时启动游戏,他会直接提示是否下载 Java,而不会使用现有的
hmcl-exported-logs-2024-04-14T09-23-49.log
第一次下载的时候会校验失败,第二次就好了
真奇怪
应该在校验失败后将校验失败的文件重新下载再校验,如果还是校验失败就报弹窗
建议在禁用或卸载前先弹出个弹窗确认一下,以防手滑
慢慢搞,这个功能还有很多优化空间~
@zkitefly
在指定了 Java 版本为 8 时启动游戏,他会直接提示是否下载 Java,而不会使用现有的
I tried using 1.16.5, and the launcher automatically selected other Java 8 on my computer to start; while the 1.20.4 version will pop up the same prompt as yours.
Edit: Starting in 21w19a Mojang increased the required Java version to 16. This version will start to show the same pop-up window as yours. Previous versions would launch with Java 8 as expected.
Edit: The same situation occurs in the following scenario:
Edit: I noticed that if I select No in the first pop-up window, another pop-up window will appear, to the effect that the Java version is incompatible. I guess the intended logic is to only show the latter popup?
Preview
I tested this build.
I downloaded 4 Javas from Java Management and then did the following in Java Path in Global Game Settings.
- Automatically Select is selected by default
- I selected Specify Java Version and tried selecting a number
- Choose one of the several Java downloads below
Something weird happens next. The selected flag keeps shuffling among the several Javas below, the Specify Java Version box keeps changing, the memory occupied by HMCL keeps soaring, and the log generates a lot of content. Configuration files are also constantly being overwritten.
The process may not be stopped even if the window is closed, and the configuration file may be lost if the process is forcibly stopped.
Log: (Deleted)
Could you provide the screen shot
An infinite recursive call is happening here and I'm thinking of a solution.
@burningtnt
Preview
Opps :(
Use this build.
Java binaries (Java 16, 17, 21) downloaded directly from Java Management do not recognize vendors. However, moving it to another location (such as the partition root) and adding it manually will recognize that its vendor is Microsoft.
The following two Javas are essentially identical.
[**:**:**] [org.jackhuang.hmcl.java.JavaManager.searchPotentialJavaExecutables/TRACE] Finished Java lookup, found 2
- JDK 21.0.2 (x86-64, Unknown): C:\Users\*\AppData\Roaming\.hmcl\java\windows-x86_64\java-runtime-delta\bin\java.exe
- JDK 21.0.2 (x86-64, Microsoft): C:\HMCL\Java\java-runtime-delta\bin\java.exe
Another: JRE 1.8.0_51 cannot detect vendor. Whether downloaded directly or moved to another location and added manually.
The following two Javas are essentially identical.
[**:**:**] [org.jackhuang.hmcl.java.JavaManager.searchPotentialJavaExecutables/TRACE] Finished Java lookup, found 2
- JRE 8u51 (x86-64, Unknown): C:\Users\*\AppData\Roaming\.hmcl\java\windows-x86_64\jre-legacy\bin\java.exe
- JRE 1.8.0_51 (x86-64, Unknown): C:\HMCL\Java\jre-legacy\bin\java.exe
Specify Java Version only seems to accept pure numbers. If you enter letters or symbols, red will appear below the box.
But if you switch from the default Automatically Select to the specific Java below, and then switch to Specify Java Version, the box on the right will be filled with an illegal string (the complete version of Java, which may contain symbols or letters).
The classic scenario of this situation: last time you set a specific Java in the launcher, this happens when you close and reopen the launcher and directly select Specify Java Version.
Preview
在指定了 Java 版本为 8 时启动游戏,他会直接提示是否下载 Java,而不会使用现有的
Although subsequent commits tried to solve this problem, they seemed to only apply to Release versions. some snapshots and pre-release versions still give error messages.
Really helpful testing! Thanks.
Java binaries (Java 16, 17, 21) downloaded directly from Java Management do not recognize vendors. However, moving it to another location (such as the partition root) and adding it manually will recognize that its vendor is Microsoft.
The following two Javas are essentially identical.
HMCL will try to read Java information in two ways:
- Read the
$JAVA_HOME/releasefile; - Run
$JAVA_HOME/bin/java -XshowSettings:properties -versionand read its output.
There are some problems with the first way:
- Unable to verify that the Java is complete;
- The
releasefile of JDK/JRE may lack some information.
But this way is much faster (no need to run these Java), so it will be used as the primary way to read Java information.
What you are experiencing is because its release file does not contain this information. Due to some rules, when you move it to another location, HMCL reads the Java information through the second way.
I have now done something to optimize this behavior and this issue should be resolved after you uninstall and reinstall Java. There may still be some edge cases where similar problems arise, but I don't think it's worth the extra effort to solve them.
Use this build.
In some cases, when selecting a specific Java binary that already exists, the box to the right of Specify Java Version will be filled with characters even though the user cannot enter it.
Preview
Feature Request: Optimize the dialog when HMCL is launched with Java 8-10 by providing a direct button to download Java 11/17
See: https://github.com/HMCL-dev/HMCL/pull/3007
Feature Request: Bundle a json into HMCL like openjfx-dependencies.json, which provides more JRE versions such as 1.8_41, 1.8_312 and 11.x.x and supports more OS.
We do need to download these versions, as #3049 requires these features.
openSUSE 的 jvm 目录是 /usr/lib64/jvm 需要添加该路径的扫描
When disabling a Java that comes from the scan when the launcher is first opened, is it possible to keep it in Java Management but make it invisible in (Global) Game Settings - Java Path; and be able to enable it again to make it available again in (Global) Game Settings - Java Path? Theoretically, disabling only temporarily stops using it, but the current logic is equivalent to removing from the Java Management
THe current operation when 'disabling' a Java is like 'uninstall'. I suggest changing the i18n to 'uninstall' to make it match with its behavior.
For the feature like 'disabling' a Java, I suggest only provides the button for Java installed by other process (not in the minecraft java dir).
https://github.com/user-attachments/assets/778a2fb8-26d7-4115-9568-6bc1371fab0d
---- Hello Minecraft! Crash Report ----
Version: 3.5.unofficial-ce12845
Time: 2024-08-02 18:22:35
Thread: Thread[JavaFX Application Thread,5,main]
Content:
java.lang.AssertionError: Unknown distribution type: class org.jackhuang.hmcl.download.java.disco.DiscoJavaDistribution
at org.jackhuang.hmcl.ui.main.JavaDownloadDialog$DownloadDiscoJava.onDownload(JavaDownloadDialog.java:286)
at org.jackhuang.hmcl.ui.main.JavaDownloadDialog$DownloadDiscoJava.lambda$new$0(JavaDownloadDialog.java:207)
at [email protected]/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at [email protected]/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at [email protected]/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at [email protected]/javafx.event.Event.fireEvent(Event.java:198)
at [email protected]/javafx.scene.Node.fireEvent(Node.java:8923)
at [email protected]/javafx.scene.control.Button.fire(Button.java:203)
at [email protected]/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:207)
at [email protected]/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
at [email protected]/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
at [email protected]/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at [email protected]/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at [email protected]/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at [email protected]/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at [email protected]/javafx.event.Event.fireEvent(Event.java:198)
at [email protected]/javafx.scene.Scene$MouseHandler.process(Scene.java:3894)
at [email protected]/javafx.scene.Scene.processMouseEvent(Scene.java:1887)
at [email protected]/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2620)
at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
at [email protected]/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
at [email protected]/com.sun.glass.ui.View.handleMouseEvent(View.java:551)
at [email protected]/com.sun.glass.ui.View.notifyMouse(View.java:937)
at [email protected]/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at [email protected]/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:316)
at java.base/java.lang.Thread.run(Thread.java:840)
-- System Details --
Operating System: Linux 5.18.17-amd64-desktop-hwe
System Architecture: x86_64
Java Architecture: amd64
Java Version: 17.0.12, BellSoft
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode, sharing), BellSoft
JVM Max Memory: 2067791872
JVM Total Memory: 78643200
JVM Free Memory: 11373232
https://github.com/HMCL-dev/HMCL/actions/runs/10011521323/job/27675110563?pr=2988
这个功能还没做完。
https://github.com/Hex-Dragon/PCL2/issues/4261
根据该 issue,或许在 HMCL 的自动查找路径时,若检测到包含 java8path_target_ 的 java 路径时或许应该排除?
建议在macOS平台检查/opt/homebrew/Cellar下所有带有openjdk前缀字符串的子目录。因为当Homebrew安装指定版本openjdk时,安装路径将会是/opt/homebrew/Cellar/openjdk@<version>。(来自 #3241 )
同时,在翻阅原JavaVersion.java文件时注意到,至少在macOS平台,可能没有考虑openjdk外的jdk检测,例如zulu。通常来讲它们应该同样位于/opt/homebrew/Cellar下。
如果没有明显问题,我计划在本周末合并本 PR。