Comments (11)
@toonvanacker I made some tests yesterday and I couldn't figure out why the API the plugin uses to launch the JShell stops to work correctly since Java 12 when launched with Gradle. I think is related with the really bad way Gradle manages the standard input and output streams, that also cause the autocomplete and history futures built in the JShell to not work, I'll add in the README a warning about the incompatibility, but at least for now I don't have more time to investigate the issue 🤷♂️
from jshell-plugin.
@toonvanacker don't worry about that, the plugins always check whether it can execute the classes
task, and it doesn't know that you already passed the task explicitly in the command line.
I should add a check to avoid the warning, but what I'm trying to say is that the message does not mean that the classes
task was not executed, it is that the jshell
task couldn't find it querying the Gradle API, but because you passed it explicitly, it was for sure executed (check the output to be sure).
from jshell-plugin.
Thank you for the quick response!
I mistook this warning for the root issue then. I should have been clearer from the start: my main issue is that JShell immediately exits, like so:
$ ./gradlew --console plain classes jshell
> Task :compileJava UP-TO-DATE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :jshellSetup
:jshell task :classes not found, be sure to compile the project first
> Task :jshell
| Welcome to JShell -- Version 13.0.1
| For an introduction type: /help intro
BUILD SUCCESSFUL in 1s
3 actionable tasks: 2 executed, 1 up-to-date
$
I'm using some Java 13 preview features, but I'm not sure if that would be at all related.
from jshell-plugin.
🤔 checking your output, the JShell console is executed, but intermediately terminated but no clues why:
> Task :jshell
| Welcome to JShell -- Version 13.0.1
| For an introduction type: /help intro
Could you try again as follow? execute the classes
task before execute the jshell
one, in two separates executions, actually there is no need to execute both in the same Gradle execution:
$ ./gradlew classes
$ ./gradlew --console plain jshell
If it does the same, the last instruction pleace add the -q
argument: ./gradlew --console plain -q jshell
.
Also, what unix shell are you running? Bash? or an alternative like Zsh? If the last, could you please execute it within a Bash console? just execute in your Zsh console bash
and you will enter into a new "bash" console session inside the Zsh one, then you can execute the commands mentioned above or your original test.
from jshell-plugin.
I'm running Bash, so that probably isn't the issue.
Sadly, neither of the above two suggestions worked out. If you have any further suggestions, I'm more than willing to try to help pinpoint the issue.
If you don't have the time, that's alright. I assume it works fine for most people, I'm probably hitting some strange edge case.
from jshell-plugin.
Sorry, I tested in the past the plugin only with Java 9 (the minimal version required) and 11 (the latest LTS by the way) and it was working, now testing it with Java 12, 13 and 14 I realized it fails in the same way it's failing you: executing the Jshell and then immediately exiting the process, and it was reported also in #1 but i did not pay attention on that time because I was implementing a refactor.
So the good news is that at least we know why is failing: it does not work with Java 12+, and I will try to fix the problem next week, meanwhile you can try it with Java 11. If it is a problem to downgrade your Java version installed, I recommend you to setup SdkMan!, I use it and it's an amazing tool to setup different environments in the same computer and without breaking the system installation.
from jshell-plugin.
Thanks for the update!
from jshell-plugin.
I appreciate the effort, in any case. Hopefully one day it'll be fixed.
from jshell-plugin.
BTW, what it works with Java 12+ is to run JShell script in a .jsh file, quote from the README:
If the plugin founds at the root of the project a JShell Script named startup.jsh, it will append to the JShell session the argument --startup startup.jsh, executing at the beginning all the instruction in the script, so you can add there all the imports, object definitions or any Java instruction that you want to execute at the begging of the session. You can override the startup script path with the project property jshell.startup in the gradle.properties file, or set the same property in the command line arguments, like:
$ gradle --console plain jshell -Pjshell.startup=/path/to/run.jsh
If you have a startup.jsh script at the root of the project but at some point you don't want to execute it nor any other startup script, just pass the jshell.startup property with an empty value: gradle --console plain jshell -Pjshell.startup=.
But once executed the instructions in the .jsh file, the session is also exited, but at least it allows you to run a small script without run the all application.
from jshell-plugin.
I had the same problem with JDK14.
./gradlew --console plain jshell
> Task :jshellSetup
:jshell task :classes not found, be sure to compile the project first
> Task :jshell
| Welcome to JShell -- Version 14.0.1
| For an introduction type: /help intro
BUILD SUCCESSFUL in 984ms
2 actionable tasks: 2 executed
jshell
just stops, no info WTF went wrong. When I specify a start script, it looks like none of my dependencies was loaded (the script errors on the first import statement).
from jshell-plugin.
Closing this because won't be fixed, and don't have any effect in the final outcome, the problem of JShell being exited earlier is not related with this, that error was fixed and the patch released yesterday: check out 1.1.0.
from jshell-plugin.
Related Issues (10)
- No Interactive Shell using Gradle 6.3 and JDK 14 HOT 4
- not working in Windows HOT 11
- jshell version != JDK version HOT 13
- Command line editing? HOT 2
- Code completion and navigation with arrow keys doesn't work HOT 1
- Non jar files should be excluded from the path sent to jshell HOT 9
- tab completion not working HOT 4
- arrow key not work HOT 4
- no new line before use of println HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jshell-plugin.