1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WSLでjupyter+Javaを使うときにClassPathを指定する

Posted at

JupyterLab+Javaを使う場合にクラスパスを設定するぞ.

設定ファイルはどこだ

$ jupyter kernelspec list

java       /path/to/jupyter/kernels/java
python3    /path/to/jupyter/kernels/python3

通常のJavaとは違うjava-libというkernelを作るぞ

$ cd /home/user_name/.local/share/jupyter/kernels/
$ mkdir java-lib
$ cd java-lib
$ ln -s ../java/ijava-1.3.0.jar
$ cp ../java/kernel.json ./
$ vi kernel.json

kernel.json
{
    "argv": [
        "java",
        "-Xmx8g",
        "-cp",
        "/path/to/lib/dir/*:/path/to/java-lib/ijava-1.3.0.jar",
        "io.github.spencerpark.ijava.IJava",
        "{connection_file}"
    ],
    "display_name": "Java-lib",
    "language": "java",
    "interrupt_mode": "message",
    "env": {

    }
}

できた.
以下のコードでクラスパスがズラズラ出てくれば成功.

Properties properties = System.getProperties();
String clsPath = properties.getProperty("java.class.path");
System.out.println(clsPath);

しかし,実行ファイルごとにクラスパスを変更することはできないようだ.
ま,特定のlibファイルにjarファイルを全部入れておくという罰当たりなやり方で何とかなりそう.

しかし,Eclipseに慣れすぎているので,補完があまり効かないJupyterLabでどこまでコードが書けるか自信がない・・・

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?