Using JShell class in JDK

so theres this class JShell that can be used same as the cli app, how can i instantiate and use it correctly? any examples?
8 Replies
JavaBot
JavaBot9mo ago
This post has been reserved for your question.
Hey @Koblížkáč! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st9mo ago
What exactly do you want to do?
JShell shell = Jshell.create();
List<SnippetEval> result = shell.eval("1+1");
System.out.println(result.getFirst().value());
JShell shell = Jshell.create();
List<SnippetEval> result = shell.eval("1+1");
System.out.println(result.getFirst().value());
Koblížkáč
KoblížkáčOP9mo ago
hmm i see, do you know if it would be possible to add a URL/InputStream as classpath?
dan1st
dan1st9mo ago
how exactly? what does it point to?
Koblížkáč
KoblížkáčOP9mo ago
well, lets say i execute it like this but its missing dependencies i have in the app which is executing it, so i want to add them to the jshell cp but they are loaded dynamically with custom classloader so they cant be added as class path
JavaBot
JavaBot9mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server