classpath
Peter Levart
peter.levart at gmail.com
Sun Feb 12 20:57:34 UTC 2017
Hi,
On 02/12/2017 04:03 PM, Michael Müller wrote:
> Hi,
>
>
> formerly I could use
>
> /classpath
> ~/Dropbox/Vortrag/ParallelStreams/ParallelStreams/target/ParallelStreams.jar
>
> | Path '~/Dropbox/Vortrag/ParallelStreams/ParallelStreams/target/
> ParallelStreams.jar' added to classpath
> jshell> import de.muellerbruehl.parallelstreams.PersonManager
>
>
> SInce this has become /env, I have trouble with it:
>
> jshell> /env -class-path
> ~/Dropbox/Vortrag/ParallelStreams/ParallelStreams/target/ParallelStreams.jar
> | Setting new options and restoring state.
>
> jshell> /env
> | --class-path
> ~/Dropbox/Vortrag/ParallelStreams/ParallelStreams/target/ParallelStreams.jar
>
> jshell> import de.muellerbruehl.parallelstreams.PersonManager
> | Error:
> | package de.muellerbruehl.parallelstreams does not exist
> | import de.muellerbruehl.parallelstreams.PersonManager;
> | ^--------------------------------------------^
>
> Although /env displays the added classpath, it is not recognized.
> To add a classpath, I have to leave the shell and restart it with the
> classpath option.
> And btw. the doc states a directory will be accepted as classpath. But
> I always have to add the fully qualified name of the jar. The
> directory only does not work :(
>
The problem seems to be the tilde "~" character you used to specify the
path to the jar file. For example:
jshell> /env --class-path ~/JavaLibs/guava-21.0.jar
| Setting new options and restoring state.
jshell> /env
| --class-path ~/JavaLibs/guava-21.0.jar
jshell> import com.google.common.base.Function;
| Error:
| package com.google.common.base does not exist
| import com.google.common.base.Function;
| ^-----------------------------^
...but...
jshell> /env --class-path /home/peter/JavaLibs/guava-21.0.jar
| Setting new options and restoring state.
jshell> /env
| --class-path /home/peter/JavaLibs/guava-21.0.jar
jshell> import com.google.common.base.Function;
jshell>
The "tilde" character is usually expanded by a UNIX shell:
bash$ echo ~
/home/peter
...but jshell seems to interpret it literally.
Should jshell treat and expand /env arguments according to the rules of
native shells on the corresponding platforms? For example, should it
expand %VARIABLE% on Windows and ${VARIABLE} or $VARIABLE on UNIX-es ?
Regards, Peter
More information about the kulla-dev
mailing list