leiningen icon indicating copy to clipboard operation
leiningen copied to clipboard

Use JAVA_HOME instead of JAVA_CMD in windows bat file?

Open didibus opened this issue 5 years ago • 5 comments

I find it weird that lein uses JAVA_CMD as the environment variable to find the path to Java if java isn't on the path. It is more standard to have JAVA_HOME point to the Java install. Only lein uses JAVA_CMD. Even the official Java doc mentions JAVA_HOME: https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/

Could we not change lein so it also checks JAVA_HOME?

didibus avatar Nov 11 '18 03:11 didibus

Sure; I haven't used many other java systems that do this, but if it's a common idiom then I'd take a patch to make it work this way. The only caveat is that it should be supported consistently across all the different implementations, and that JAVA_CMD should still take precedence if set, because it's more specific.

technomancy avatar Nov 11 '18 19:11 technomancy

In my experience this is a common idiom, there's even java_home program that comes with Java for determining the directory of your Java home if you have multiple JDK's installed. For one third-party example, see Cassandra.

$ /usr/libexec/java_home -v 1.8
/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home

danielcompton avatar Nov 12 '18 00:11 danielcompton

Guess we could get that in for the next minor release and deprecate JAVA_CMD for 3.0?

winks avatar Nov 12 '18 11:11 winks

Yeah, I would take a patch for this.

technomancy avatar Nov 28 '18 17:11 technomancy

@technomancy !USERPROFILE! in lein.bat should be replaced with %USERPROFILE%

Krchi avatar May 31 '19 15:05 Krchi