SpencerPark / IJava

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

Does IJava support JShell commands? Can we use IJava to interactively develop JavaFX GUI code? #57

Open pdeitel opened 5 years ago

pdeitel commented 5 years ago

Thanks for creating this kernel. A couple of questions:

  1. Are any JShell commands supported by the kernel? If so, how do we use them? For example, it might be handy to be able to /open a file of snippets/code and have them become part of the current notebook's executed snippets.

  2. JShell has an option to load a bunch of print, println and printf methods as shorthands for the corresponding System.out object's methods. It would be nice to be able to do the same in IJava.

  3. Can we execute JavaFX code in IJava?

Thanks! Paul

SpencerPark commented 5 years ago

Hi Paul,

  1. There is the %load magic (just realized I forgot to document it in the magics docs while looking for something to link) which is similar to jshell's open. It takes a file (or notebook) as an argument and runs it as if the contents were put into a cell and executed. If there are other specific things you are interested please open an issue.

  2. In the configuring section of the README there is some information regarding how to change your startup scripts. ijava-jshell-init.jshell is always loaded but you can add others by setting the environment variable (or using the options in the install.py for setting such variables). Set IJAVA_STARTUP_SCRIPTS_PATH to provide a glob of files to load when a kernel starts. Set IJAVA_STARTUP_SCRIPT to run the value of that variable as code when the kernel starts.

  3. You should be able run JavaFX but I'm not sure it will behave like you would expect. Code would be run on the server which would be fine if running jupyter locally since the server is also the machine viewing the notebook. The window would then appear as it regularly does, not inside the notebook.

    I'm working on an implementation of the widget protocol to use ipywidgets from the java kernel if any interactive ui is what you are looking for. Not sure of the effort (or even usefulness) of trying to stick fx on top of that but it could definitely be interesting.

pdeitel commented 5 years ago

Thanks again. I'll take a look at all of these.

kartisrini commented 4 years ago

Hi, The IJava Kernel is awesome and a great tool to teach and/or learn Java using Jupyter. I am interested in being able to use most if not all of the JShell commands from within a Jupyter Notebook. With the new Jupyter Lab, it would even be possible to create a class and then have it load from within a Notebook and see it execute which will be of great use. Can it be considered a feature request if this is already not available. Of particular interest would /var, /methods, /list, /imports, /types, /edit, /drop and /reload. It would also be nice to be able to augment the classpath to a running kernel, may be drop a jar or classes in the path defined in the startup script and then restart the kernel from within the notebook.

Thanks Kartik