Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure: how to explicitly choose JVM in the environment with Leiningen/Lighttable

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!

like image 528
Yu Shen Avatar asked Oct 20 '14 14:10

Yu Shen


2 Answers

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.

like image 79
Carl Smotricz Avatar answered Oct 27 '22 07:10

Carl Smotricz


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.

like image 39
Bill Avatar answered Oct 27 '22 09:10

Bill