| <!-- ***** BEGIN LICENSE BLOCK ***** | |
| - Version: MPL 1.1/GPL 2.0 | |
| - | |
| - The contents of this file are subject to the Mozilla Public License Version | |
| - 1.1 (the "License"); you may not use this file except in compliance with | |
| - the License. You may obtain a copy of the License at | |
| - http://www.mozilla.org/MPL/ | |
| - | |
| - Software distributed under the License is distributed on an "AS IS" basis, | |
| - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
| - for the specific language governing rights and limitations under the | |
| - License. | |
| - | |
| - The Original Code is Rhino code, released May 6, 1999. | |
| - | |
| - The Initial Developer of the Original Code is | |
| - Netscape Communications Corporation. | |
| - Portions created by the Initial Developer are Copyright (C) 1997-1999 | |
| - the Initial Developer. All Rights Reserved. | |
| - | |
| - Contributor(s): | |
| - | |
| - Alternatively, the contents of this file may be used under the terms of | |
| - the GNU General Public License Version 2 or later (the "GPL"), in which | |
| - case the provisions of the GPL are applicable instead of those above. If | |
| - you wish to allow use of your version of this file only under the terms of | |
| - the GPL and not to allow others to use your version of this file under the | |
| - MPL, indicate your decision by deleting the provisions above and replacing | |
| - them with the notice and other provisions required by the GPL. If you do | |
| - not delete the provisions above, a recipient may use your version of this | |
| - file under either the MPL or the GPL. | |
| - | |
| - ***** END LICENSE BLOCK ***** --> | |
| <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> | |
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | |
| <meta name="Author" content="Norris Boyd"> | |
| <meta name="GENERATOR" content="Mozilla/4.7 [en] (WinNT; U) [Netscape]"> | |
| <title>JavaScript Compiler</title> | |
| </head> | |
| <body bgcolor="#FFFFFF"> | |
| <center> | |
| <h1> | |
| JavaScript Compiler</h1></center> | |
| The JavaScript compiler translates JavaScript source into Java class files. | |
| The resulting Java class files can then be loaded and executed at another | |
| time, providing a convenient method for transfering JavaScript, and for | |
| avoiding translation cost. | |
| <p>Note that the top-level functions available to the shell (such as <tt>print</tt>) | |
| are <i>not</i> available to compiled scripts when they are run outside | |
| the shell. | |
| <br> | |
| <h2> | |
| Invoking the Compiler</h2> | |
| <tt>java org.mozilla.javascript.tools.jsc.Main</tt> [<i>options</i>] <i>file1</i><tt>.js</tt> | |
| [<i>file2</i><tt>.js</tt>...] | |
| <p>where <i>options</i> are: | |
| <p><tt>-extends <i>java-class-name</i></tt> | |
| <blockquote>Specifies that a java class extending the Java class <i>java-class-name</i> | |
| should be generated from the incoming JavaScript source file. Each global | |
| function in the source file is made a method of the generated class, overriding | |
| any methods in the base class by the same name.</blockquote> | |
| <tt>-implements <i>java-intf-name</i></tt> | |
| <blockquote>Specifies that a java class implementing the Java interface | |
| <i><tt>java-intf-name</tt></i> | |
| should be generated from the incoming JavaScript source file. Each global | |
| function in the source file is made a method of the generated class, implementing | |
| any methods in the interface by the same name.</blockquote> | |
| <tt>-debug</tt> | |
| <br><tt>-g</tt> | |
| <ul>Specifies that debug information should be generated. May not be combined | |
| with optimization at an <i>optLevel</i> greater than zero.</ul> | |
| <tt>-nosource</tt> | |
| <ul>Does not save the source in the class file. Functions and scripts compiled | |
| this way cannot be decompiled. This option can be used to avoid distributing | |
| source or simply to save space in the resulting class file.</ul> | |
| <tt>-o </tt><i>outputFile</i> | |
| <ul>Writes the class file to the given file (which should end in <tt>.class</tt>). | |
| The string <i>outputFile</i> must be a writable filename.</ul> | |
| <tt>-opt </tt><i>optLevel</i> | |
| <br><tt>-O</tt> <i>optLevel</i> | |
| <ul>Optimizes at level <i>optLevel</i>, which must be an integer between | |
| -1 and 9. See <a href="opt.html">Optimization</a> for more details. If | |
| <i>optLevel</i> | |
| is greater than zero, <tt>-debug</tt> may not be specified.</ul> | |
| <tt>-package</tt> <i>packageName</i> | |
| <ul>Specifies the package to generate the class into. The string <i>packageName</i> | |
| must be composed of valid identifier characters optionally separated by | |
| periods.</ul> | |
| <tt>-version </tt><i>versionNumber</i> | |
| <ul>Specifies the language version to compile with. The string <i>versionNumber</i> | |
| must be one of <tt>100</tt>, <tt>110</tt>, <tt>120</tt>, <tt>130</tt>, | |
| <tt>140</tt>, <tt>150</tt>, or <tt>160</tt>. See <a href="overview.html#versions">JavaScript Language | |
| Versions</a> for more information on language versions.</ul> | |
| <h2> | |
| Examples</h2> | |
| <tt>$ cat test.js</tt> | |
| <br><tt>java.lang.System.out.println("hi, mom!");</tt> | |
| <br><tt>$ java org.mozilla.javascript.tools.jsc.Main test.js</tt> | |
| <br><tt>$ ls *.class</tt> | |
| <br><tt>test.class</tt> | |
| <br><tt>$ java test</tt> | |
| <br><tt>hi, mom!</tt> | |
| <p><tt>$ java org.mozilla.javascript.tools.jsc.Main -extends java.applet.Applet | |
| \</tt> | |
| <br><tt> -implements java.lang.Runnable NervousText.js</tt> | |
| <br> | |
| <p> | |
| <hr WIDTH="100%"> | |
| <br><a href="index.html">back to top</a> | |
| </body> | |
| </html> |