Can't use wildcards in IJAVA_CLASSPATH option
See original GitHub issueI’m using IJava to explore some Java libraries that I want to familiarise myself with, and it’s working out really well for me so far. However, I came upon a minor issue when pointing the IJava classpath to multiple libraries in multiple .jar files stored in the same directory.
Explicitly pointing to the individual .jar files in kernel.json works perfectly:
"IJAVA_CLASSPATH" : "/path/to/lib/Lib1.jar:/path/to/lib/Lib2.jar:/path/to/lib/Lib3.jar"
However, it is possible to use wildcards in Java classpaths to point to multiple .jar files in one directory. For example, this works for me when launching jshell
:
jshell --class-path "/path/to/lib/*"
However, if I try to similarly use a wildcard in kernel.json,
"IJAVA_CLASSPATH" : "/path/to/lib/*"
then IJava reports that it does not work:
| import path.to.class.ClassName;
package path.to.class does not exist
It’s a small issue with an easy workaround (explicitly pointing to all the libraries), but I thought I’d report it regardless.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Related to this, there is now a magic
%jars
that can be used to add jars to the classpath at runtime (also using this glob syntax). See magics.md for more information about that.Hi @erlendviggen, thanks for reporting the issue.
I’ve been playing around with various options in the JShell API but unfortunately I can’t get anything to do the expansion. Little disappointed that
addToClasspath
doesn’t do this so it looks like we will have to handle it ourselves.The wildcard patterns that classpath usually supports are very restricted (just a single
*
to match a directory and nothing after it) so it shouldn’t be too difficult to implement. But since we are going to implement it we can go one step better and just support glob syntax (getPathMatcher).