Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "JSDT/Debug/Rhino/Using Rhino Console"

< JSDT‎ | Debug‎ | Rhino
Line 1: Line 1:
{{JSDT-Debug}}
+
{{JSDT-Debug}}  
  
== Overview ==
+
== Overview ==
  
The Rhino console can be a powerful way to work with JavaScript within Rhino. Simply put, the Rhino console allows you to interact with the Rhino interpreter using System.in and System.out. You can also debug these interactions with a Remote JavaScript launch configuration.
+
The Rhino console can be a powerful way to work with JavaScript within Rhino. Simply put, the Rhino console allows you to interact with the Rhino interpreter using System.in and System.out. You can also debug these interactions with a Remote JavaScript launch configuration.  
  
The details of the console, and what it supports can be found [http://www.mozilla.org/rhino/shell.html here].
+
The details of the console, and what it supports can be found [http://www.mozilla.org/rhino/shell.html here].  
  
== Starting the Console ==
+
== Starting the Console ==
  
There are many ways to start the console and we will discuss two of them here:
+
There are many ways to start the console and we will discuss two of them here:  
# start the console from an Eclipse workspace
+
# start the console from a system terminal
+
  
=== From Eclipse ===
+
#start the console from an Eclipse workspace
 +
#start the console from a system terminal
  
To start the console from within an Eclipse workspace, we first have to get the source for the <code>org.eclipse.wst.jsdt.debug.rhino.debugger</code> project. This project can be obtained by simply importing the team project set for the JSDT debugger found [http://www.eclipse.org/webtools/jsdt/psf/jsdt-debug.psf here].
+
=== From Eclipse  ===
 +
 
 +
To start the console from within an Eclipse workspace, we first have to get the source for the <code>org.eclipse.wst.jsdt.debug.rhino.debugger</code> project. This project can be obtained by simply importing the team project set for the JSDT debugger found [http://www.eclipse.org/webtools/jsdt/psf/jsdt-debug.psf here].  
  
 
Once the source has been added to your workspace and has been built, we have to create a new Java Application launch configuration for the <code>org.eclipse.wst.jsdt.debug.rhino.debugger.shell.DebugShell</code> class. When creating the new launch configuration, there are some options for the launch that we should mention.  
 
Once the source has been added to your workspace and has been built, we have to create a new Java Application launch configuration for the <code>org.eclipse.wst.jsdt.debug.rhino.debugger.shell.DebugShell</code> class. When creating the new launch configuration, there are some options for the launch that we should mention.  
  
The following table summarizes the supported options for launching the Rhino console.
+
The following table summarizes the supported options for launching the Rhino console.<br>
  
 
{| border="1" cellspacing="0" cellpadding="5" align="left"
 
{| border="1" cellspacing="0" cellpadding="5" align="left"
! Option
+
|-
! What it does
+
! Option  
 +
! What it does  
 
! Example
 
! Example
|-
 
| -port
 
| Allows you to specify the port that the console should communicate on
 
| -port=5000
 
 
|-
 
|-
| -suspend
+
| port
| Allows to specify if the console should start and then wait until a debugger connects before continuing
+
| Allows you to specify the port that the console should communicate on
| -suspend=true OR -suspend=y
+
| port 5000
 
|-
 
|-
| -trace
+
| suspend
| Allows you to specify if the console should output status messages
+
| Allows to specify if the console should start and then wait until a debugger connects before continuing
| -trace=true
+
| suspend true OR -suspend=y
 +
|-
 +
| trace  
 +
| Allows you to specify if the console should output status messages  
 +
| trace true
 
|}
 
|}
  
 
At this point you should have a new Java Application launch configuration that looks like the following (assuming you added the <code>-port</code> and <code>-suspend</code> options).
 
At this point you should have a new Java Application launch configuration that looks like the following (assuming you added the <code>-port</code> and <code>-suspend</code> options).
  
[[Image:Debugshell-main-config.png|frame|The Main tab of the new configuration]]
+
[[Image:Debugshell-main-config.png|frame|The Main tab of the new configuration]]  
 
+
[[Image:Debugshell-arg-config.png|frame|The Arguments tab of the new configuration]]
+
  
 +
[[Image:Debugshell-arg-config.png|frame|The Arguments tab of the new configuration]]
 +
 
Regardless of your use of the <code>-suspend</code> option, at this point the console can be connected to by a remote debugger.  
 
Regardless of your use of the <code>-suspend</code> option, at this point the console can be connected to by a remote debugger.  
  
=== From the Terminal ===
 
  
=== Attaching the Debugger ===
 
  
At this point you should have the Rhino console up and running and see something like the following, either in your terminal or the Eclipse console:
+
=== From the Terminal  ===
  
<pre>
+
=== Attaching the Debugger  ===
Rhino debugger
+
 
 +
At this point you should have the Rhino console up and running and see something like the following, either in your terminal or the Eclipse console:
 +
<pre>Rhino debugger
 
Start at time: November 19, 2010 11:21:51 CST AM
 
Start at time: November 19, 2010 11:21:51 CST AM
 
Listening to socket onport: 9000
 
Listening to socket onport: 9000
 
Started suspended - waiting for client resume...
 
Started suspended - waiting for client resume...
</pre>
+
</pre>  
 
+
The next thing we want to do is attach the remote debugger to be able to debug whatever we do in the console.  
The next thing we want to do is attach the remote debugger to be able to debug whatever we do in the console.
+
  
== Console Commands ==
+
== Console Commands ==
  
Very good information about all of the supported commands and their effects can be found [http://www.mozilla.org/rhino/shell.html here].
+
Very good information about all of the supported commands and their effects can be found [http://www.mozilla.org/rhino/shell.html here].  
  
 
== Examples ==
 
== Examples ==

Revision as of 13:37, 19 November 2010

JSDT Debug
Website
Download
Community
Mailing ListForumsIRCmattermost
Issues
OpenHelp WantedBug Day
Contribute
Browse SourceProject Set File

Overview

The Rhino console can be a powerful way to work with JavaScript within Rhino. Simply put, the Rhino console allows you to interact with the Rhino interpreter using System.in and System.out. You can also debug these interactions with a Remote JavaScript launch configuration.

The details of the console, and what it supports can be found here.

Starting the Console

There are many ways to start the console and we will discuss two of them here:

  1. start the console from an Eclipse workspace
  2. start the console from a system terminal

From Eclipse

To start the console from within an Eclipse workspace, we first have to get the source for the org.eclipse.wst.jsdt.debug.rhino.debugger project. This project can be obtained by simply importing the team project set for the JSDT debugger found here.

Once the source has been added to your workspace and has been built, we have to create a new Java Application launch configuration for the org.eclipse.wst.jsdt.debug.rhino.debugger.shell.DebugShell class. When creating the new launch configuration, there are some options for the launch that we should mention.

The following table summarizes the supported options for launching the Rhino console.

Option What it does Example
port Allows you to specify the port that the console should communicate on port 5000
suspend Allows to specify if the console should start and then wait until a debugger connects before continuing suspend true OR -suspend=y
trace Allows you to specify if the console should output status messages trace true

At this point you should have a new Java Application launch configuration that looks like the following (assuming you added the -port and -suspend options).

The Main tab of the new configuration
The Arguments tab of the new configuration

Regardless of your use of the -suspend option, at this point the console can be connected to by a remote debugger.


From the Terminal

Attaching the Debugger

At this point you should have the Rhino console up and running and see something like the following, either in your terminal or the Eclipse console:

Rhino debugger
Start at time: November 19, 2010 11:21:51 CST AM
Listening to socket onport: 9000
Started suspended - waiting for client resume...

The next thing we want to do is attach the remote debugger to be able to debug whatever we do in the console.

Console Commands

Very good information about all of the supported commands and their effects can be found here.

Examples

Back to the top