|
2 | 2 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
3 | 3 |
|
4 | 4 | <meta charset="utf-8">
|
5 |
| -<meta name="generator" content="quarto-1.4.553"> |
| 5 | +<meta name="generator" content="quarto-1.4.555"> |
6 | 6 |
|
7 | 7 | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
8 | 8 |
|
9 | 9 | <meta name="author" content="Stephan Saalfeld">
|
10 | 10 | <meta name="dcterms.date" content="2022-06-05">
|
| 11 | +<meta name="description" content="Follow these instructions to setup the IJava jupyter kernel by Spencer Park."> |
11 | 12 |
|
12 | 13 | <title>ImgLib2 and BigDataViewer projects - Setup the IJava jupyter kernel</title>
|
13 | 14 | <style>
|
|
106 | 107 |
|
107 | 108 | <link rel="stylesheet" href="../../styles.css">
|
108 | 109 | <meta property="og:title" content="ImgLib2 and BigDataViewer projects - Setup the IJava jupyter kernel">
|
109 |
| -<meta property="og:description" content=""> |
| 110 | +<meta property="og:description" content="Follow these instructions to setup the IJava jupyter kernel by Spencer Park."> |
110 | 111 | <meta property="og:site_name" content="ImgLib2 and BigDataViewer projects">
|
111 | 112 | </head>
|
112 | 113 |
|
|
208 | 209 | <header id="title-block-header" class="quarto-title-block default page-columns page-full">
|
209 | 210 | <div class="quarto-title-banner page-columns page-full">
|
210 | 211 | <div class="quarto-title column-body">
|
211 |
| - <div class="quarto-title-block"><div><h1 class="title">Setup the IJava jupyter kernel</h1><button type="button" class="btn code-tools-button" id="quarto-code-tools-source" data-quarto-source-url="https://github.com/imglib/imglib2-www/blob/main/blog/2022-06-05-setup-ijava-jupyter-kernel/2022-06-05-setup-ijava-jupyter-kernel.qmd"><i class="bi"></i> Code</button></div></div> |
212 |
| - <div class="quarto-categories"> |
| 212 | + <div class="quarto-title-block"><div><h1 class="title">Setup the IJava jupyter kernel</h1><button type="button" class="btn code-tools-button" id="quarto-code-tools-source" data-quarto-source-url="https://github.com/imglib/imglib2-www/blob/main/blog/2022-06-05-setup-ijava-jupyter-kernel/setup-ijava-jupyter-kernel.md"><i class="bi"></i> Code</button></div></div> |
| 213 | + <div> |
| 214 | + <div class="description"> |
| 215 | + Follow these instructions to setup the IJava jupyter kernel by Spencer Park. |
| 216 | + </div> |
| 217 | + </div> |
| 218 | + <div class="quarto-categories"> |
213 | 219 | <div class="quarto-category">jupyter</div>
|
214 | 220 | <div class="quarto-category">ijava</div>
|
215 | 221 | <div class="quarto-category">jshell</div>
|
|
236 | 242 | </div>
|
237 | 243 | </div>
|
238 | 244 |
|
| 245 | + <div> |
| 246 | + <div class="quarto-title-meta-heading">Modified</div> |
| 247 | + <div class="quarto-title-meta-contents"> |
| 248 | + <p class="date-modified">April 3, 2024</p> |
| 249 | + </div> |
| 250 | + </div> |
239 | 251 |
|
240 | 252 | </div>
|
241 | 253 |
|
|
251 | 263 |
|
252 | 264 |
|
253 | 265 |
|
254 |
| -<p>In this blog, we will show code snippets and examples to make the best use of <a href="https://github.com/imglib/imglib2">ImgLib2</a>, <a href="https://github.com/bigdataviewer/bigdataviewer-core">BigDataViewer</a>, and friends. ImgLib2 is written to be fast and we will run code that needs to be compiled, so we cannot use any of the various interpreted scripting languages like Python, Groovy, or Javascript. Instead, we will use the <a href="https://docs.oracle.com/javase/9/jshell/introduction-jshell.htm#JSHEL-GUID-630F27C8-1195-4989-9F6B-2C51D46F52C8">JShell tool</a> that you can use directly in a terminal or through <a href="https://github.com/SpencerPark/IJava">Spencer Park’s IJava jupyter kernel</a>. You can also follow these tutorials in your own Java project and use your preferred IDE, but Jupyter notebooks are a great teaching tool. Since jupyter is written in Python and most popular with the Python community, let’s follow their ways and first thing create a virtual environment with conda. The lack of version controlled dependency management for Python projects makes it necessary that practically every project must run in a container or virtual environment because the dependencies of different projects almost inevitably collide. Conda is the most popular of several attempts to address this situation. Conda cannot currently be installed from the default Ubuntu repositories, so much about that, but the <a href="https://docs.conda.io/projects/conda/en/latest/user-guide/install/rpm-debian.html">installation instructions</a> are tolerable, there is a PPA. Now let’s create an environment for jupyter:</p> |
| 266 | +<p>In this blog, we will show code snippets and examples to make the best use of <a href="https://github.com/imglib/imglib2">ImgLib2</a>, <a href="https://github.com/bigdataviewer/bigdataviewer-core">BigDataViewer</a>, and friends. ImgLib2 is written to be fast and we will run code that needs to be compiled, so we cannot use any of the various interpreted scripting languages like Python, Groovy, or Javascript. Instead, we will use the <a href="https://docs.oracle.com/javase/9/jshell/introduction-jshell.htm#JSHEL-GUID-630F27C8-1195-4989-9F6B-2C51D46F52C8">JShell tool</a> that you can use directly in a terminal or through <a href="https://github.com/saalfeldlab/IJava">Spencer Park’s IJava jupyter kernel</a>. You can also follow these tutorials in your own Java project and use your preferred IDE, but Jupyter notebooks are a great teaching tool. Since jupyter is written in Python and most popular with the Python community, let’s follow their ways and first thing create a virtual environment with conda. The lack of version controlled dependency management for Python projects makes it necessary that practically every project must run in a container or virtual environment because the dependencies of different projects almost inevitably collide. Conda is the most popular of several attempts to address this situation. Conda cannot currently be installed from the default Ubuntu repositories, so much about that, but the <a href="https://docs.conda.io/projects/conda/en/latest/user-guide/install/rpm-debian.html">installation instructions</a> are tolerable, there is a PPA. Now let’s create an environment for jupyter:</p> |
255 | 267 | <pre><code>conda create -n jshell-jupyter python=3
|
256 | 268 | conda init bash
|
257 | 269 | conda activate jshell-jupyter
|
|
265 | 277 | ./gradlew publishToMavenLocal
|
266 | 278 |
|
267 | 279 | cd ..
|
268 |
| -git clone https://github.com/hanslovsky/IJava.git |
| 280 | +git clone https://github.com/saalfeldlab/IJava.git |
269 | 281 | cd IJava/
|
270 |
| -git checkout hanslovsky/gradle-7.4.2 |
271 | 282 | ./gradlew installKernel</code></pre>
|
272 | 283 | <p>Now check if the kernel is installed, this should print something like this</p>
|
273 | 284 | <pre><code>jupyter kernelspec list
|
|
277 | 288 | python3 /home/saalfeld/anaconda3/envs/jshell-jupyter/share/jupyter/kernels/python3</code></pre>
|
278 | 289 | <p>You can now start the jupyter notebook server</p>
|
279 | 290 | <pre><code>jupyter notebook --kernel=java</code></pre>
|
280 |
| -<p>And experiment with the examples. <a href="https://github.com/SpencerPark/IJava">Spencer Park’s IJava jupyter kernel</a> makes it very easy to include dependencies. You can include the relevant snippets from a Maven POM into a tagged code block, e.g.</p> |
| 291 | +<p>And experiment with the examples. <a href="https://github.com/saalfeldlab/IJava">Spencer Park’s IJava jupyter kernel</a> makes it very easy to include dependencies. You can include the relevant snippets from a Maven POM into a tagged code block, e.g.</p> |
281 | 292 | <div class="sourceCode" id="cb6"><pre class="sourceCode xml code-with-copy"><code class="sourceCode xml"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>%%loadFromPOM</span>
|
282 | 293 | <span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><<span class="kw">repository</span>></span>
|
283 | 294 | <span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <<span class="kw">id</span>>scijava.public</<span class="kw">id</span>></span>
|
|
288 | 299 | <span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a> <<span class="kw">artifactId</span>>bigdataviewer-vistools</<span class="kw">artifactId</span>></span>
|
289 | 300 | <span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a> <<span class="kw">version</span>>1.0.0-beta-29</<span class="kw">version</span>></span>
|
290 | 301 | <span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a></<span class="kw">dependency</span>></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 302 | +<p>or in gradle short notation</p> |
| 303 | +<pre><code>%mavenRepo scijava.public https://maven.scijava.org/content/groups/public |
| 304 | +%maven sc.fiji:bigdataviewer-vistools:1.0.0-beta-29</code></pre> |
291 | 305 | <p>If you prefer to run <a href="https://docs.oracle.com/javase/9/jshell/introduction-jshell.htm#JSHEL-GUID-630F27C8-1195-4989-9F6B-2C51D46F52C8">JShell</a> directly, you can pull in the dependencies from a complete Maven POM with John Pooth’s Maven Jshell plugin</p>
|
292 | 306 | <pre><code>mvn compile com.github.johnpoth:jshell-maven-plugin:1.3:run</code></pre>
|
293 | 307 | <p>Happy JShelling!</p>
|
|
0 commit comments