Navigating to Java Class and Method definitionsλ︎
, g g with the cursor on a Java class or method name in a Clojure source code file will jump to its definition. This is useful if you are using Java interop in your Clojure code or using Java libraries as part of your project, e.g. Java swing code example
Add the Java sources locally to also enable searching with ripgrep or ag. Or add a java-source alias when starting a REPL.
Adding a deps.edn alias for Java sourcesλ︎
Using an alias is the recommended way to include Java sources for Clojure CLI projects, as those sources are a only used in the development workflow.
:src/java17
{:extra-deps
{java-sources {:local/root "/usr/lib/jvm/openjdk-17/lib/src.zip"}}}
:src/clojure
{:extra-deps
{org.clojure/source {:local/root "~/projects/community/clojure.org/clojure"}}}
practicalli/example deps.edn includes example aliases for java sources
Location of Sources
The location of the Java src.zip file may differ on your operating system. You can also extract the src.zip
file and use the extracted sources.
Include Java sources alias during jack-inλ︎
Add a .dir-locals.el
file to the root of your Clojure project to include the java sources alias when running cider-jack-in.
((clojure-mode . ((cider-clojure-cli-aliases . ":src/java17")
(cider-preferred-build-tool . "clojure-cli"))))
Or include both Java and Clojure Java sources
((clojure-mode . ((cider-clojure-cli-aliases . ":src/java17:src/clojure")
(cider-preferred-build-tool . "clojure-cli"))))
Adding Local Clojure and Java sourcesλ︎
Navigate to Java source files using local copies of the Java Source code. Download and extracting the Clojure and Java sources to your computer.
Java source code is part of the JDK installation and can be found at:
Java source code is part of the JDK installation and can be found at:
Download the latest Clojure sources from Maven
Extract the Java src.zip
file and clojure-x-x-x-sources.jar
file
Add cider-jdk-src-paths
configuration to dotspacemacs/user-config
in the .spacemacs
file. Change the paths if you extracted the files to a different location.