Samples
subfolder
of your TextPad installation (on my Windows XP computer it was
"C:\Program Files\TextPad 5\Samples
" and on my 64-bit machine it
was "C:\Program Files (x86)\TextPad 5\Samples
." Note: On my
Windows Vista machine, the folder was set to "read only", so I saved the
file to the desktop, dragged it to the correct folder, and told the
computer that it was okay to apply administrator privileges.
Document class name: JavaScript Class members: *.jsWhen it prompts for syntax file name, select
javascript.syn
and click
on "Enable syntax highlighting".
function foo() { print("Hello, world!"); } foo(); // call the functionSave it to
test.js
. When you go to save, be careful to
have "Save as Type" set to "All files". TextPad has a habit of
saving to Text files in which case it would save it as
test.js.txt
. When you save it, you should see colors
appear for the keywords.
Description: JavaScript files Wildcards: *.jsYou can then click on the "Move up" button several times to move it to the top so that TextPad will default to the sml file type. Be sure to click on Apply and OK.
.js
and in the Description text field, type
something like "JavaScript files". Then click on Add, Apply, OK. Once you've
done this, you can double-click on your .js files and they'll open in
TextPad.
java.exe
and you'll find
it in the directory c:\Program Files\Java\jdk_VERSIONNUMBER\bin
(it was
c:\Program Files (x86)\Java\jdk_VERSIONNUMBER\bin
on my 64-bit machine).
Navigate to the file, select it, and then click on Apply.
java
command you just created. You
need to change a few settings. Change the "Parameters" from $File
to
-jar "PATH_TO_RHINO.JAR" $File
(no quotes). Uncheck the box for "Capture
output". Check the box for "Save all documents first". Leave everything
else alone. Click on Apply and OK.
So you may instead want to set your "Parameters" to just "-jar PATH_TO_RHINO.JAR" , and then make sure the "Initial Folder" is set to $FileDir . Then when you run Rhino you will get an empty interpreter, where you can type:
load("YOUR_FILE_NAME.js");
The program you want it to run is called javaw.exe
(note the W) and you'll find
it in the directory c:\Program Files\Java\jdk_VERSIONNUMBER\bin
(it was
c:\Program Files (x86)\Java\jdk_VERSIONNUMBER\bin
on my 64-bit machine).
Navigate to the file, select it, and then click on Apply.
Expand the Tools menu (you'll probably see a "+" that you need to click
on). Under that, select the javaw
command you just created. You
need to change a few settings. Change the "Parameters" from $File
to
-classpath "PATH_TO_RHINO.jar" org.mozilla.javascript.tools.debugger.Main $File
(no quotes). Uncheck the box for "Capture
output". Check the box for "Save all documents first". Leave everything
else alone. Click on Apply and OK.
java
. You may want to rename it to something like "Run in Rhino".
(Ditto for the debugger one; maybe rename it to "Debug in Rhino".)
Try selecting it. It should launch the interpreter, load your
file, and leave you at a prompt to interact with the interpreter.
On Mac, just save rhino.jar
to a known directory on your machine. To run the interpreter, open a Terminal and type:
java -jar PATH_TO_RHINO\rhino.jar
or, to run a .js file as a program, type:
java -jar PATH_TO_RHINO\rhino.jar filename
I don't use a Mac and don't know Mac text editors, so I don't have any detailed instructions for setting them up. If you find a way to integrate Rhino/JavaScript with your editor, feel free to post about this on the course message board.
rhino.jar
to a directory and then set up an alias
on your machine so that when you type rhino
, the following command will run:
rlwrap java -jar PATH_TO_RHINO.jar filenameFor example, you could edit your Bash startup files and add an alias such as:
rhino=rlwrap java -jar PATH_TO_RHINO.jarOr you can set up an exectuable shell script such as the following:
#!/bin/sh rlwrap java -jar /usr/lib/java/rhino.jar $*If anyone has problems, post a message to the message board or email the instructor and we'll try to figure out what is going on.