On the Clojure Getting Started page, it shows to start the REPL like this:
java -cp clojure-1.5.1.jar clojure.main
The first argument is a file, which can also be specified via the environment variable CLASSPATH. But what is clojure.main?
It is the main class of the JAR file: org.clojure/clojure/1.5.1/META-INF/maven/org.clojure/ clojure/pom.xml
<archive>
<manifest>
<mainClass>clojure.main</mainClass>
</manifest>
</archive>
For more info : Setting an Application's Entry Point
Related
Trying to get a project that uses figwheel running in Cursive. I can get everything running on the command line using run -m clojure.main script/figwheel.clj but when I follow the instructions for running within Cursive I get the following error:
java.io.FileNotFoundException: Could not locate figwheel_sidecar/repl_api__init.class or figwheel_sidecar/repl_api.clj on classpath.
Does anyone know why this works on the command line and not within Cursive? I believe I followed the directions that the project provided. Do I need to set my classpath somewhere in Cursive.
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!
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.
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.
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).
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.
I am getting the below error whenever I try M-x nrepl-jack-in -
error in process sentinel: Could not start nREPL server: /usr/bin/lein: line 260: java: command not found
I am able to start the repl without any issues by lein repl or lein2 repl - both work.
Thanks,
Murtaza
I had the same problem. Let me guess, you are launching Emacs from the application launcher? Applications launched this way apparently do not use your .bashrc file. If you do your PATH set up in your ~/.profile file instead it should work. You'll need to log out and in for it to take effect though.
You may have an different environment inside emacs from inside your shell. Is Java installed in the same place as lein? If you type M-x shell, and run java -help there does it work? What about "M-x shell-command java -help"
To run Clojure files from command line, I'm using a zhs alias I added to my .zshrc:
alias 'clojure=java -cp /home/sinan/cclojure/lib/clojure-1.2.1.jar:/home/sinan/cclojure/lib/clojure-contrib-1.2.0.jar clojure.main -i '
With this, I can run my Clojure app like this:
clojure test3.clj
But it doesn't work when I want to send command line parameters.
➜ src clojure test3.clj arg1 arg2
Exception in thread "main" java.io.FileNotFoundException: arg1 (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at clojure.lang.Compiler.loadFile(Compiler.java:5817)
at clojure.main$load_script.invoke(main.clj:221)
at clojure.main$script_opt.invoke(main.clj:273)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:457)
at clojure.lang.Var.invoke(Var.java:377)
at clojure.lang.AFn.applyToHelper(AFn.java:172)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
What am I doing wrong? Is my way of running Clojure apps wrong?
Thanks.
you just need to specify name of script, without -i key after clojure.main. In your case, clojure.main thinks, that test.clj is program to eval before (and it do it), while arg1 is script to execute
See description of option for clojure.main/main function
Has anyone recently tried to setup slimv for clojure that would be willing to describe how to do so? Slimv will currently autodetect lisp on my machine but fails to load on .clj files. I've also added the following to my .vimrc
let g:slimv_swank_clojure = '! xterm -e lein swank &'
but it has no effect (lein is installed and executable).
Sorry if this is a basic question but I am very new to both vim and clojure.
First you should check in your terminal command prompt that lein swank does really run the swank server from within the directory where your .clj file resides. If it doesn't start then you need to make a command that runs the swank server, then embed it in '! xterm -e {swank_command} &' and store it in g:slimv_swank_clojure.
If the swank command looks OK, then you should check it from within Slimv via :echo SlimvSwankCommand() that prints the actual swank command built and used by Slimv.
You may also run the swank server in a separate terminal window outside of Vim, Slimv will connect it if the port number is the same on both sides (4005 by default).
There is another Swank server embedded in Slimv, but this is only autodetected if the lein command does not exits for the user (and g:slimv_swank_clojure is not explicitly defined).
If still no luck then please contact me, I'm the author of Slimv, you can find my email address in the documentation.
Unless you are certain there are something you need in Slimv, there's very good plugin called VimClojure.