diff --git a/roles/winroom/tasks/JDK.yml b/roles/winroom/tasks/JDK.yml index 2930ac1..9f09113 100644 --- a/roles/winroom/tasks/JDK.yml +++ b/roles/winroom/tasks/JDK.yml @@ -1,29 +1,28 @@ -- name: Set OpenJDK version - set_fact: - target_version: "18.0.2" - -- name: Install OpenJDK +- name: Install Oracle JDK win_chocolatey: - name: openjdk - version: "{{ target_version }}" + name: oraclejdk + +- name: Find Java version + win_reg_stat: + path: HKLM:\SOFTWARE\JavaSoft\JDK + name: CurrentVersion + register: reg + +- name: Find Java home + win_reg_stat: + path: "HKLM:\\SOFTWARE\\JavaSoft\\JDK\\{{ reg['value'] }}" + name: JavaHome + register: reg - name: Set JAVA_HOME win_environment: name: JAVA_HOME - value: "C:\\Program Files\\OpenJDK\\jdk-{{ target_version }}" + value: "{{ reg['raw_value'] }}" level: machine -# XAMPP insists on looking for Java and failing without this. -- name: Set registry key for OpenJDK +- name: Disable Java updates win_regedit: - path: HKLM:\SOFTWARE\JavaSoft\Java Development Kit - -- name: Create .jar file type - win_regedit: - path: "HKCR:\\.jar" - data: "jarfile" - -- name: Create association for jarfile - win_regedit: - path: "HKCR:\\jarfile\\shell\\open\\command" - data: C:\Program Files\OpenJDK\jdk-{{ target_version }}\bin\javaw.exe -jar "%1" + path: HKLM:\SOFTWARE\WOW6432Node\JavaSoft\Java Update\Policy + name: EnableJavaUpdate + type: dword + data: 0