Skip to content

Commit

Permalink
Update install-java.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Lafcadia committed May 2, 2024
1 parent 216cf35 commit f66a3fc
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions install-java.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
import jdk
import os

try:
jdk.install("8") if ask("服务器版本是否小于等于 1.16.5? ") else jdk.install("19")
except Exception as e:
print(f"安装失败: {e}")
exit_()
script_license()

path = os.path.expanduser("~") + "\\.jdk"
java_path = os.path.join(path, os.listdir(path)[0])
def java_install():
try:
jdk.install("8") if ask("服务器版本是否小于等于 1.16.5? ") else jdk.install("19")
except Exception as e:
print(f"安装失败: {e}")
exit_()

# os.system(f"setx JAVA_HOME {java_path}")
os.system(f'setx "Path" "%Path%;%JAVA_HOME%\\bin" /m')
path = os.path.expanduser("~") + "\\.jdk"
java_path = os.path.join(path, os.listdir(path)[0])

print("安装完成")
exit_()
# 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_()

0 comments on commit f66a3fc

Please sign in to comment.