You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a Google Colab gist that shows how I'm using %classpath and how the classpath isn't updated afterwards.
Am I using the magic incorrectly? I was hoping to be able import my own classes to use in a Google Colab notebook, but I can't get IJava to recognize them.
Thanks for any help!
The text was updated successfully, but these errors were encountered:
You're using the magic correctly (%classpath <path>).
The system property (System.getProperty("java.class.path")) isn't updated because that is the app classpath for the kernel itself but the managed JShell's classpath is still updated. When you run code in a cell it is compiled and run with a different classpath set through the various magic commands.
If you are distributing class files (rather than a jar) then they should be in folders matching their package structure and the root path added with %classpath.
e.g. with a class called HelloWorld in package com.example; located at /content/sample_data/com/example/HelloWorld.class, then you can use it with the following:
The system property (System.getProperty("java.class.path")) isn't updated because that is the app classpath for the kernel itself but the managed JShell's classpath is still updated. When you run code in a cell it is compiled and run with a different classpath set through the various magic commands.
Thanks for clearing that up! I'm guessing a distinction similar to the kernel/JShell one is why the output of HelloWorld doesn't appear as cell output for a cell whose code is:
For context, I use this code:
(from this gist) to load IJava as the kernel in a Google Colab notebook, but no matter what I do, the classpath is always
Here's a Google Colab gist that shows how I'm using
%classpath
and how the classpath isn't updated afterwards.Am I using the magic incorrectly? I was hoping to be able import my own classes to use in a Google Colab notebook, but I can't get IJava to recognize them.
Thanks for any help!
The text was updated successfully, but these errors were encountered: