Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 345344

Summary: Cannot set additional Java classpath for Rhino Javascript debugging
Product: [WebTools] JSDT Reporter: Jim Garrison <jgarrison>
Component: DebugAssignee: Project Inbox <jsdt.debug-inbox>
Status: CLOSED DUPLICATE QA Contact: Michael Rennie <Michael_Rennie>
Severity: normal    
Priority: P3 CC: thatnitind
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Jim Garrison CLA 2011-05-10 18:06:09 EDT
Build Identifier: Indigo 20110505-1223; JSDT 1.3.0.v201103031824

When attempting to debug a JS file that calls Java classes, there does not appear to be a way to provide additional Java classpath info to the local Rhino launch so that the Javascript can access those classes.

I'm working with a workspace that has both Java and Javascript natures.  The project contains both Java and Javascript source and the js scripts refer to some of the Java classes.

When attempting to debug a simple .js file that instantiates one of the Java classes, I get the following error at the point of instantiation:

js: uncaught JavaScript runtime exception: TypeError: [JavaPackage com.troux.test.JSTestClass] is not a function, it is object.

Based on prior experience I think this means the class is not defined, and Rhino is assuming com.* is a Java package.  If I run the same code in a Rhino command-line shell started up with the correct classpath references, then it works.  Also, displaying the value of "com.troux.test.JSTestClass" in the Rhino shell gives type "JavaClass" instead of "JavaPackage".

I cannot find any place in the UI where I can indicate the JAVA classpath to be used for the local Rhino debug launch.  I need for it to resolve classes in the same project, and also in other projects in the same workspace, as in my "real" situation I will have several related projects in the same workspace.

Note that without the ability to specify a Java classpath on the Rhino launch, local Rhino debugging will be relegated to "toy" status, useful only for debugging pure Javascript with no external Java references.

Reproducible: Always
Comment 1 Jim Garrison CLA 2011-05-10 18:27:15 EDT
Additional info - In debug view, the process properties show the command line as

C:\Program Files\Java\jre6\bin\javaw.exe -Dfile.encoding=Cp1252 -cp C:\dev2\tools\eclipse\plugins\org.mozilla.javascript_1.7.2.v201005080400.jar;C:\dev2\tools\eclipse\plugins\org.eclipse.wst.jsdt.debug.transport_1.0.0.v201008101442.jar;C:\dev2\tools\eclipse\plugins\org.eclipse.wst.jsdt.debug.rhino.debugger_1.0.200.v201103080228.jar org.eclipse.wst.jsdt.debug.rhino.debugger.shell.DebugMain -port 64796 -suspend y -version 170 -encoding Cp1252 -opt -1 -f C:\dev\src\clarity\product\applications\clarity-client\src\scripts\test.js

What is needed is a way to add libraries and class directories to the classpath used here.
Comment 2 Michael Rennie CLA 2011-05-10 18:55:36 EDT

*** This bug has been marked as a duplicate of bug 343142 ***