Inno Setup - Setting Java Environment Variable

前端 未结 2 598
一个人的身影
一个人的身影 2020-12-11 05:39

I am using Inno Setup to make an installer for a project I am working on, and I need it to set the java environment variable, so that when they run cmd they don\'t get a

2条回答
  •  误落风尘
    2020-12-11 06:23

    Assuming Java is installed in its default location program files/Java, something like this should work in your case:

    [Registry]
    ; set PATH
    Root: HKCU; Subkey: "Environment"; ValueType:string; ValueName:"PATH"; ValueData:"{olddata};{pf}\Java\bin"; Flags: preservestringtype
    ; set JAVA_HOME
    Root: HKCU; Subkey: "Environment"; ValueType:string; ValueName:"JAVA_HOME"; ValueData:"{pf}\Java"; Flags: preservestringtype
    
    [Setup]
    ; Tell Windows Explorer to reload the environment
    ChangesEnvironment=yes
    

    I'm not sure which environment variable you want to set -- PATH or JAVA_HOME -- so I've added them both.

    Changing PATH shouldn't be necessary since the Java installer tends to add itself to the path; IIRC it copies java.exe and javaw.exe to one of the system directories.

提交回复
热议问题