SpencerPark / IJava

A Jupyter kernel for executing Java code.
MIT License
1.1k stars 215 forks source link

is it possible to limit which java packages require no import statements? #156

Open david-romano opened 7 months ago

david-romano commented 7 months ago

Context: I'm using IJava to teach Java via Google Colab Jupyter notebooks, and I just realized that no import statements are necessary for, say, access to the contents of the java.io package. I'd like to mimic the environment students will encounter when they start using an IDE, where the default is often that only the contents of the java.lang package are available without import. Is this something I could easily mimic with IJava?

Thanks, David Romano

andrus commented 4 months ago

(Editing my earlier answer)

The source of default imports is this file: https://github.com/SpencerPark/IJava/blob/master/src/main/resources/ijava-jshell-init.jshell , which is loaded unconditionally on kernel startup. So the only way to get rid of it is to create a custom kernel build. Should probably make it conditional in JJava.

andrus commented 3 months ago

We may actually be working on this as a part of another feature in JJava: https://github.com/dflib/jjava/issues/28