I have set JAVA_HOME as below from batch file, but it still pointing to what is installed in C drive
@echo on
set JAVA_HOME=D:\xxxx\JAVA\jdk1.7.0_80
set M2_HOME=D:\xxxx\JAVA\apache-maven-3.3.9
set PATH=%JAVA_HOME%\bin;%M2_HOME%\bin;%PATH%
CMD
Please let me know any other way to override default JAVA_HOME. I need to change JAVA_HOME for maven to use new JDK for compilation
您可以将其设置为“控制面板/系统/系统高级配置”,然后按“环境变量”按钮并在用户变量框中设置JAVA_HOME
Try using the setx command.
Set modifies the current shell's (window) environment values, and the change is available immediately, but it is temporary. the change will not affect other shells that are running, and as soon as you close the shell, the new value is lost until such time as you run set again.
setx modifies the value permenantly, which affects all future shells, but does not modify the environment of the shells already running. you have to exit the shell and reopen it before the change will be available, but the value will remain modified until you change it again.
Syntax for setx is : setx variableName variableValue
Source : Difference between set and setx
Credit goes to Frank Thomas
Atlast I found what is the issue. My JDK is corrupt or missing crucial jars.
System to pick up JAVA location and set it as JAVA_HOME, jdk should contain java.exe, javaw.exe, javaws.exe in bin folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.