-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jshell version != JDK version #12
Comments
That's weird! What you get executing |
|
I do have Java11 installed separately on my machine, but at least my environment for this project should be entirely Java17, and I've got hopefully all the right things set in
|
What the plugin basically does is to invoke the command with a prebuild set of arguments, see: jshell-plugin/src/main/groovy/com/github/mrsarm/jshell/plugin/JShellPlugin.groovy Lines 101 to 109 in 2b3b04c
So, for some reason the
|
Yeah, if I run the commandline jshell, I get Java17. I'm thinking that maybe this is an old Gradle process that's caching old environment variables. Nonetheless, you really do want to launch a jshell that matches whatever Java version is used for compiling and running the code, as opposed to whatever is in the search path first. |
Good point ! in the past changing the
The reason is because in this commit b6aebbb we changed the way we call JShell, executing a shell process instead of using the JShell API from Java. The reason was that the API stopped to work in Java 12 and above, not sure why. So this section explaining how to use the Back to your problem, that it's in part due the problems described above, and as you pointed out:
Try also execute Gradle with the |
Sure enough, killing and restarting the Gradle daemon made it (finally) do the right thing. Meanwhile, when I do this, I don't get tab-based autocomplete on my code (e.g., |
Good to know that ! About auto-completion, unfortunately that is something that doesn't work due Gradle limitations, checkout https://github.com/mrsarm/jshell-plugin#tab-completion-not-working. What I do suggest, also as pointed out in the section above, it's to call Gradle with
|
Hmm. Feature request: a new Gradle action, "printJShellCommand" or similar, which dumps something you can cut-and-paste, then run on your own. (Use case: doing a live-coding demo with JShell, where autocomplete keeps you from making a mess of the screen.) |
Yea , I was thinking about adding something like that, maybe instead of an alternative command, as an argument, because JShell currently supports another optional argument and I may add others in the future. It can be something like:
The only drawback is that the output command can be really long, here is an example of how it would looks like in a Spring app I have that actually doesn't have more dependencies other than Spring and spring-ctx (Spring has a lot of dependencies, same for any modern framework):
The command above has exactly 4708 characters ! Moreover, if you pipe the output in a bash file ( So what I have in mind, but it can take a while to develop, it's actually add a flag to create a script called But for now I'm short of time to work on it 😞 |
BTW, if you want to "build" a script like the above with JShell, you can get the list of all the dependencies ready for copy & paste executing the plugin with the
You will see more logs than usual while Gradle and the plugin start. Look for
( Plus, if you want to execute a |
I'm a fan of the |
(Apparently the extracted shell command that I want, for my own project, is 8260 characters long. Sheesh.) |
I've got everything in my project using Java17:
Similarly, my
build.gradle
specifies Java17 in all the right places and if I callSystem.getProperty("java.version")
, it prints "17.0.1".But, when I run
./gradlew --console plain jshell
, I get this:Is this configurable somewhere?
The text was updated successfully, but these errors were encountered: