Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » JSDT calling Java from Javascript - How to set Java Classpath for Rhino?
JSDT calling Java from Javascript - How to set Java Classpath for Rhino? [message #669594] Tue, 10 May 2011 21:13
Jim Garrison is currently offline Jim GarrisonFriend
Messages: 57
Registered: July 2009
When running JS local Rhino debugging in Indigo M7 (20110505), I can't seem to find a way to give Rhino access to Java classes, either in the same project or in projects I have open in the same workspace. For example:

Java class:

package com.troux.test;
public class JSTestClass 
	public JSTestClass()


var x = new com.troux.test.JSTestClass();

Output from running test.js as local Rhino debug:

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

The fact that Rhino thinks com.troux.test.JSTestClass is a "JavaPackage" is a reflection of the default import behavior where it assumes that anything in the com.* namespace it doesn't recognize is a package until it finds otherwise. Playing around in the Rhino console, with the classpath set correctly, I can run the same script, in which case com.troux.test.JSTestClass is identified as being a "JavaClass", not "JavaPackage", and I am able to invoke the constructor.
Previous Topic:IWAB0523E Error moving resource: ...... Could not read from source when writing file
Next Topic:Can standalone js files be debugged in Rhino in eclipse?
Goto Forum:

Current Time: Sat Nov 28 05:06:56 GMT 2020

Powered by FUDForum. Page generated in 0.02473 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top