Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2003

Tip: Looking for answers? Try searching our database.

Java as a scripting language.

Thread view: 
William Korvine - 19 Nov 2003 20:32 GMT
I have been Googling (and still am), but thought I'd just ask.

I have an application that needs a scripting language. I have
written my own interpreted language (a small subset of C++),
but am considering using Java as an alternative.

I need a hint on the following: How can I make Java use the
named objects within my application. For example, my current
language (ClearScript) might have the following code:

void foo( void )
{
  Record newrec = NewRecord( 12 );  // New record of type 12.
  newrec.Name = "Something";  // Change the 'Name' field of the record.
  newrec.Data = Globals.Functions.Calculate();
  newrec.Id   = Globals.States.CurrentId++;
}

Most of these identifiers are user controlled. 'Record' is a
type that has hard-coded meaning to the application. 'NewRecord()'
is a function supplied by the application to create 'Record's.
'Calculate()' is user-written.

I would like similer code to work in Java, but I can't
find if it's possible to expose these objects to Java.

Any hints would be helpful.

William Korvine

PS: My experience with Java is minimal. I am a C++ Windows programmer.
Jonas Kongslund - 20 Nov 2003 00:35 GMT
> I need a hint on the following: How can I make Java use the
> named objects within my application. For example, my current
> language (ClearScript) might have the following code:
[snip]
> I would like similer code to work in Java, but I can't
> find if it's possible to expose these objects to Java.

You may want to take a look at <http://jakarta.apache.org/bsf/index.html>.

Signature

Jonas Kongslund

FISH - 20 Nov 2003 12:16 GMT
[snipped...]

> I would like similer code to work in Java, but I can't
> find if it's possible to expose these objects to Java.
[quoted text clipped - 4 lines]
>
> PS: My experience with Java is minimal. I am a C++ Windows programmer.

There are a number of scripting implementations in Java.  Jython, for
example, is a Java version of Python.  It quite cleverly merges itself
into the existing Java 'runtime', with near-seemless access to the Java
API's and any other packages.  However, I personally found it a little
too large and resource hungry.

One alternative worth a look is Rhino - an old Mozilla-based project
which provides Javascript (ECMAScript) 1.5 support for Java.  Although
none of the Java API's are automatically mirrored into the Javascript
'domain', there is a facility to manually map Java objects into Java-
script, making them visible to your scripts, while allowing Java to
trap/handle accesses to properties, etc.  It's more work for you, but
the Jar is quite small, it appears to run at a decent speed, and
Javascript is very well known and supported on-line (important if end
users are to use the scripting facilities of your product!)

http://www.mozilla.org/rhino/

-FISH-   ><


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.