-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Lafcadia/main
Automatic Java Installment
- Loading branch information
Showing
2 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from utils import * | ||
install_package("install-jdk") | ||
import jdk | ||
import os | ||
|
||
script_license() | ||
|
||
def java_install(): | ||
try: | ||
jdk.install("8") if ask("服务器版本是否小于等于 1.16.5? ") else jdk.install("19") | ||
except Exception as e: | ||
print(f"安装失败: {e}") | ||
exit_() | ||
|
||
path = os.path.expanduser("~") + "\\.jdk" | ||
java_path = os.path.join(path, os.listdir(path)[0]) | ||
|
||
# os.system(f"setx JAVA_HOME {java_path}") | ||
# os.system(f'setx "Path" "%Path%;%JAVA_HOME%\\bin" /m') | ||
print("安装完成") | ||
|
||
if __name__ == "__main__": | ||
java_install() | ||
exit_() |