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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

重构 Java 管理 #2988

wants to merge 3 commits into from

Conversation

Glavo
Copy link
Member

@Glavo Glavo commented Apr 13, 2024

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

image

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

@burningtnt
Copy link
Member

burningtnt commented May 21, 2024

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.

}

@Nullable
public static JavaRuntime findSuitableJava(Collection<JavaRuntime> javaRuntimes, GameVersionNumber gameVersion, Version version) throws InterruptedException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method never throws InterruptedException.

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.

None yet

4 participants