UNPKG

epubjs

Version:

Render ePub documents in the browser, across many devices

20 lines (19 loc) 3.94 kB
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><title>BeanShell Commands</title><link rel="stylesheet" href="core.css" type="text/css"/><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"/></head><body><div class="sect1" title="BeanShell Commands"><div class="titlepage"><div><div><h1 class="title"><a id="learnjava3-APP-B-SECT-3"/>BeanShell Commands</h1></div></div></div><p><a id="idx11247" class="indexterm"/>BeanShell comes with a number of useful built-in commands in the form of Java methods. These commands are implemented as BeanShell scripts, and are supplied in the <span class="emphasis"><em>bsh</em></span> JAR file. You can make your own commands by defining methods in your own scripts or adding them to your classpath. See the BeanShell user’s manual for more information.</p><p>One important BeanShell command is <a id="I_indexterm_id839043" class="indexterm"/><code class="literal">print()</code>, which displays values. <code class="literal">print()</code> does pretty much the same thing as <code class="literal">System.out.println()</code> except that it ensures the output always goes to the command line (if you have multiple windows open). <code class="literal">print()</code> also displays some types of objects (such as arrays) more verbosely than Java would. Another very useful command is <a id="I_indexterm_id839073" class="indexterm"/><code class="literal">show()</code>, which toggles on and off automatic printing of the result of every line you type. (You can turn this on if you want to see every result value.)</p><p>Here are a few other examples of BeanShell commands:</p><div class="variablelist"><dl><dt><span class="term"><a id="I_indexterm_id839091" class="indexterm"/> <a id="I_indexterm_id839098" class="indexterm"/> <code class="literal">source()</code>, <code class="literal">run()</code></span></dt><dd><p>Reads a script into this interpreter, or runs it in a new interpreter</p></dd><dt><span class="term"><code class="literal">frame()</code></span></dt><dd><p><a id="I_indexterm_id839126" class="indexterm"/>Displays an AWT or Swing component in a frame</p></dd><dt><span class="term"><a id="I_indexterm_id839135" class="indexterm"/> <a id="I_indexterm_id839142" class="indexterm"/> <code class="literal">load()</code>, <code class="literal">save()</code></span></dt><dd><p>Loads or saves serializable objects (such as JavaBeans)</p></dd><dt><span class="term"><code class="literal">cd()<a id="I_indexterm_id839168" class="indexterm"/></code><br/></span><span class="term"><code class="literal">cat()<a id="I_indexterm_id839178" class="indexterm"/></code><br/></span><span class="term"><code class="literal">dir()<a id="I_indexterm_id839189" class="indexterm"/></code><br/></span><span class="term"><code class="literal">pwd()</code></span></dt><dd><p>Unix-like shell commands<a id="I_indexterm_id839203" class="indexterm"/></p></dd><dt><span class="term"><code class="literal">exec()</code></span></dt><dd><p><a id="I_indexterm_id839216" class="indexterm"/>Runs a native application</p></dd><dt><span class="term"><code class="literal">addClassPath()<a id="I_indexterm_id839229" class="indexterm"/></code><br/></span><span class="term"><code class="literal">reloadClasses()</code></span></dt><dd><p><a id="I_indexterm_id839242" class="indexterm"/>Modifies the classpath or reload classes</p></dd><dt><span class="term"><code class="literal">javap()</code></span></dt><dd><p><a id="I_indexterm_id839258" class="indexterm"/>Prints a javap-style class description for the class or object specified</p></dd></dl></div><p>See the BeanShell user’s manual for a full list of commands.<a id="I_indexterm_id839268" class="indexterm"/></p></div></body></html>