8
votes

In my Windows 7 (64 bits) environment, I have quite a few JVM available:

C:\Program Files (x86)\Java\j2re1.4.2_12\bin\client\jvm.dll
C:\Program Files (x86)\Java\jre6\bin\client\jvm.dll
D:\programs\Java\jdk1.7.0_45\jre\bin\server\jvm.dll
D:\programs\Java\jre7\bin\server\jvm.dll

Currently, with Lighttable/Leiningen (I don't know which makes the choice, and how), it uses

C:\Program Files (x86)\Java\j2re1.4.2_12\bin\client\jvm.dll

But I really would like to try

D:\programs\Java\jdk1.7.0_45\jre\bin\server\jvm.dll

It's even more puzzling that when I type

java -version

I got the following:

D:\yushen>java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

It seems that's what I want to have inside Lighttable/Leinengen.

Could you show me how to make the explicit choice/configuration?

I tried Google, but couldn't find some leads.

Thanks a lot!

4

4 Answers

9
votes

I found a Leiningen profile in

$HOME/.lein/profiles.clj

For me on Windows, $HOME was D:\Users\carl . More generally, it's the directory Windows will (usually) dump you in if you start the shell using CMD . This contained:

{:user
  {
  :java-cmd "F:\\JDK8\\bin\\java.exe"
  :plugins [

    ]
   }
}

...which I was able to change to good effect.

6
votes

Put the JDK's bin directory in your path first. It's the surest way.

More detail. Windows, you can use the where command to see what version of an executable. It's either where java or where java.exe You can also look at your path from the command prompt by typing path. If you're launching something from the command line, and it's not undertaking strange measures to find the JVM, it should come up with the first one in your path, which should agree with the results of running the where command.

If the where command is coming up with something you don't expect, either add the right directory to your path before the entry that's coming up or rearrange your path so it's coming up first.

To test this in leiningen, start a repl, and evaluate this.

(println (System/getProperty "java.version"))

e.g.

Yoyo-2:Desktop bill$ lein repl
(System/getPnREPL server started on port 61475 on host 127.0.0.1 - nrepl://127.0.0.1:61475
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_20-b26
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

ruser=> (System/getProperty "java.version")
"1.8.0_20"

In my experience, Leiningen has always used the version of java it finds in the path. No experience with light table though.

3
votes

For Leiningen, you can edit lein.bat to point exactly to your desired Java SDK version. I don't know if the same could apply to LightTable.

Or you can set a global JAVA_HOME. That is really Googleable (or DuckDuckGo-able).

2
votes

Finally, I found this link: http://leiningen-win-installer.djpowell.net/

After running the installer, it has the function to re-configure leiningen, using it, I was able to configure my old leiningen to use my desired JDK: D:\programs\Java\jdk1.7.0_45\bin\java.exe, then the JVM instance in leiningen/lighttable is the desired one now.

The moral of the story: leiningen needs to be reconfigured with newly installed JDK with the configuration functionality of leiningen-win-installer.

It might be possible to configure leiningen manually, but I hadn't found a way to do yet. I tried to manually configure through my project.clj with java-command option, it didn't work.