Forum Stats

  • 3,727,354 Users
  • 2,245,375 Discussions
  • 7,852,756 Comments

Discussions

JAVA_HOME on Windows

David Madden
David Madden Member Posts: 2 Green Ribbon
edited August 2020 in SQLcl

Hi,

Why does SQLcl on Windows not use JAVA_HOME as the version of Java to use if it's set? I assumed it did this or used the PATH initially to identify the location of java.exe to use.

Looking at the debug output when running SQLcl I can see it checks the following:

Paths:

..\..\jdk\jre\bin\java.exe

Registry keys:

64-bit search: SOFTWARE\JavaSoft\Java Runtime Environment...

32-bit search: SOFTWARE\JavaSoft\Java Runtime Environment...

64-bit search: SOFTWARE\JavaSoft\Java Development Kit...

32-bit search: SOFTWARE\JavaSoft\Java Development Kit...

64-bit search: SOFTWARE\JavaSoft\JRE...

32-bit search: SOFTWARE\JavaSoft\JRE...

64-bit search: SOFTWARE\JavaSoft\JDK...

32-bit search: SOFTWARE\JavaSoft\JDK...

64-bit search: SOFTWARE\IBM\Java Runtime Environment...

32-bit search: SOFTWARE\IBM\Java Runtime Environment...

64-bit search: SOFTWARE\IBM\Java Development Kit...

32-bit search: SOFTWARE\IBM\Java Development Kit...

64-bit search: SOFTWARE\IBM\Java2 Runtime Environment...

32-bit search: SOFTWARE\IBM\Java2 Runtime Environment...

64-bit search: SOFTWARE\IBM\Java Development Kit...

32-bit search: SOFTWARE\IBM\Java Development Kit...

But never JAVA_HOME or PATH, why?

Incidentally this caused me quite a bit of head scratching to work out why my installation was not working.

David.

David Madden

Best Answer

  • Glen Conway
    Glen Conway Member Posts: 859 Gold Badge
    edited August 2020 Accepted Answer

    That second link I posted above talks about how the SQL Developer team uses Launch4j - Cross-platform Java executable wrapper to build it's exe files.  I assume the way they configure it, if no JRE is found at ..\..\jdk\jre relative to the location of sql.exe, then Launch4J searches for the highest Java JRE installed on your machine.

    That behavior can definitely make life tougher, leading you to add a JRE inside the SQLcl install at ..\..\jdk\jre relative to the location of sql.exe as a last resort.  Otherwise, I suppose you could try to create your own sql.bat file to behave like the bash script for Linux, but few will want to bother with that.

    Edit: If you do, start with this 18.1 version hack in and make any necessary changes for it to work with SQLcl 20.2.

    David Madden

Answers

Sign In or Register to comment.