Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重构 Java 管理 #2988

Merged
merged 15 commits into from
Oct 5, 2024
Merged

重构 Java 管理 #2988

merged 15 commits into from
Oct 5, 2024

Conversation

Glavo
Copy link
Member

@Glavo Glavo commented Apr 13, 2024

  • 在设置中增加 Java 管理页面,用户可通过该页面安装、添加、查看、禁用或卸载 Java;
  • 优化 Java 扫描逻辑;
  • 优化 Java 自动选择逻辑;
  • 支持用户指定所使用的 Java 版本。

截图 2024-10-17 02-58-03

image

暂未测试,晚点再说。

@zkitefly

This comment was marked as resolved.

@zkitefly

This comment was marked as resolved.

@zkitefly

This comment was marked as resolved.

@zkitefly

This comment was marked as resolved.

@burningtnt
Copy link
Member

慢慢搞,这个功能还有很多优化空间~

@3gf8jv4dv

This comment was marked as resolved.

@zkitefly

This comment was marked as outdated.

@3gf8jv4dv

This comment was marked as resolved.

@burningtnt

This comment was marked as outdated.

@Glavo

This comment was marked as outdated.

@3gf8jv4dv

This comment was marked as outdated.

@burningtnt

This comment was marked as outdated.

@3gf8jv4dv

This comment was marked as resolved.

@3gf8jv4dv

This comment was marked as resolved.

@3gf8jv4dv
Copy link
Contributor

3gf8jv4dv commented Apr 15, 2024

在指定了 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.

Preview

Specify Java Version 8, Game version 21w19a
01

Specify Java Version 8, Game version 1.17
02

Specify Java Version 16, Game version 1.18-pre2
03

Specify Java Version 16, Game version 1.18
04

Specify Java Version 17, Game version 24w14a
06

Specify Java Version 17, Game version 1.20.5-pre1
07

@burningtnt
Copy link
Member

Really helpful testing! Thanks.

@Glavo
Copy link
Member Author

Glavo commented Apr 15, 2024

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:

  1. Read the $JAVA_HOME/release file;
  2. Run $JAVA_HOME/bin/java -XshowSettings:properties -version and read its output.

There are some problems with the first way:

  • Unable to verify that the Java is complete;
  • The release file 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.

@3gf8jv4dv
Copy link
Contributor

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

00

@burningtnt
Copy link
Member

Feature Request: Optimize the dialog when HMCL is launched with Java 8-10 by providing a direct button to download Java 11/17

See: #3007

@zkitefly

This comment was marked as off-topic.

@Glavo

This comment was marked as outdated.

@Glavo Glavo marked this pull request as draft August 2, 2024 11:42
@zkitefly
Copy link
Member

Hex-Dragon/PCL2#4261

根据该 issue,或许在 HMCL 的自动查找路径时,若检测到包含 java8path_target_ 的 java 路径时或许应该排除?

@Arcadi4

This comment was marked as resolved.

3gf8jv4dv

This comment was marked as resolved.

@Glavo Glavo marked this pull request as ready for review October 1, 2024 09:49
HMCL/src/main/resources/assets/lang/I18N.properties Outdated Show resolved Hide resolved
HMCL/src/main/resources/assets/lang/I18N.properties Outdated Show resolved Hide resolved
HMCL/src/main/resources/assets/lang/I18N.properties Outdated Show resolved Hide resolved
HMCL/src/main/resources/assets/lang/I18N_zh.properties Outdated Show resolved Hide resolved
HMCL/src/main/resources/assets/lang/I18N_zh.properties Outdated Show resolved Hide resolved
HMCL/src/main/resources/assets/lang/I18N.properties Outdated Show resolved Hide resolved
HMCL/src/main/resources/assets/lang/I18N.properties Outdated Show resolved Hide resolved
@Glavo
Copy link
Member Author

Glavo commented Oct 5, 2024

如果没有明显问题,我计划在本周末合并本 PR。

@Glavo Glavo merged commit 7e4d437 into HMCL-dev:main Oct 5, 2024
3 checks passed
@Glavo Glavo deleted the java-manager branch October 5, 2024 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants