{"id":77,"date":"2022-06-26T18:20:30","date_gmt":"2022-06-26T18:20:30","guid":{"rendered":"https:\/\/blog.kevinyohe.dev\/?p=77"},"modified":"2022-06-26T18:47:40","modified_gmt":"2022-06-26T18:47:40","slug":"jshell","status":"publish","type":"post","link":"https:\/\/blog.kevinyohe.dev\/?p=77","title":{"rendered":"Jshell"},"content":{"rendered":"\n<p>A REPL<\/p>\n\n\n\n<p>type \/exit to quit<\/p>\n\n\n\n<p>Requires Java 9+, use &#8211;class-path to add libraries to jshell to be able to create those objects.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code alignfull\"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nPS C:\\devtools&gt; java -version\njava version &quot;11.0.12&quot; 2021-07-20 LTS\nJava(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237)\nJava HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)\nPS C:\\devtools&gt; jshell\n|  Welcome to JShell -- Version 11.0.12\n|  For an introduction type: \/help intro\n\njshell&gt; \/env --class-path c\ncommons-collections4-4.4-bin.zip   commons-collections4-4.4\/\n\n&lt;press tab again to see synopsis&gt;\njshell&gt; \/env --class-path commons-collections4-4.4\/c\ncommons-collections4-4.4-javadoc.jar        commons-collections4-4.4-sources.jar\ncommons-collections4-4.4-test-sources.jar   commons-collections4-4.4-tests.jar\ncommons-collections4-4.4.jar\n\n&lt;press tab again to see synopsis&gt;\njshell&gt; \/env --class-path commons-collections4-4.4\/commons-collections4-4.4.jar\n|  Setting new options and restoring state.\n\njshel\n\njshell&gt; import org.apache.commons.collections4.*\n\njshell&gt; Bag b = new Ha\nHashMap(     HashSet(     Hashtable(\njshell&gt; Bag b = new HashBag();\n|  Error:\n|  cannot find symbol\n|    symbol:   class HashBag\n|  Bag b = new HashBag();\n|              ^-----^\n\njshell&gt; import org.apache.commons.collections4.bag.HashBag\n\njshell&gt; Bag b = new HashBag();\nb ==&gt; &#x5B;]\n\njshell&gt; b.add\nadd(      addAll(\njshell&gt; b.add(\nb\n\nSignatures:\nboolean Bag&lt;E&gt;.add(E)\nboolean Bag&lt;E&gt;.add(E, int)\n\n&lt;press tab again to see documentation&gt;\njshell&gt; b.add(&quot;FOO&quot;, 10);\n|  Warning:\n|  unchecked call to add(E,int) as a member of the raw type org.apache.commons.collections4.Bag\n|  b.add(&quot;FOO&quot;, 10);\n|  ^--------------^\n$4 ==&gt; true\n<\/pre><\/div>\n\n\n<p>\/save filename.jsh to save commands in a file for later use<\/p>\n\n\n\n<p>\/open filename.jsh to open a local file again<\/p>\n\n\n\n<p>\/vars to display all the variables in scope<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A REPL type \/exit to quit Requires Java 9+, use &#8211;class-path to add libraries to jshell to be able to create those objects. \/save filename.jsh to save commands in a file for later use \/open filename.jsh to open a local file again \/vars to display all the variables in scope<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-77","post","type-post","status-publish","format-standard","hentry","category-uncategorized","entry"],"_links":{"self":[{"href":"https:\/\/blog.kevinyohe.dev\/index.php?rest_route=\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kevinyohe.dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kevinyohe.dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kevinyohe.dev\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kevinyohe.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=77"}],"version-history":[{"count":4,"href":"https:\/\/blog.kevinyohe.dev\/index.php?rest_route=\/wp\/v2\/posts\/77\/revisions"}],"predecessor-version":[{"id":81,"href":"https:\/\/blog.kevinyohe.dev\/index.php?rest_route=\/wp\/v2\/posts\/77\/revisions\/81"}],"wp:attachment":[{"href":"https:\/\/blog.kevinyohe.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kevinyohe.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kevinyohe.dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}