473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Java as a scripting language.

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.
Jul 17 '05 #1
2 1717
William Korvine wrote:
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>.

--
Jonas Kongslund
Jul 17 '05 #2
William Korvine <ko*****@hotmail.com> wrote in message news:<Xn*******************************@66.185.95. 104>...

[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.

Any hints would be helpful.

William Korvine

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- ><>
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
1
by: bezeee | last post by:
At my work we are in the process of building a tool to test an XML based API. Basically, XML in and XML out over http. Currently, there are two engines that do all of the schema validations, xml...
114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
6
by: Jens Thiede | last post by:
Q 1: I've not been using C++ much yet, but is it true that C++ is an unfriendly language to code in *OR*, as I think, is it just a case of C people, coding in C and calling it C++? Q 2: What...
5
by: TZESENG | last post by:
DECEMBER 13, 2005 . Editions: N. America | Europe | Asia | Edition Preference News Analysis By Steve Hamm Source: http://www.businessweek.com/technology/content/dec2005/tc20051213_042973.htm...
6
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a...
5
by: Ankur | last post by:
Hi Folks, I am new for this group. I want to clarify one thing what's a basic difference between Client Side Java Script and Server Side Java Script. how we can differentiate it. Why we called...
66
by: flarosa | last post by:
Hi, I'm wondering if I can get a reasonably civil (without starting any huge wars) opinion on how server-side PHP compares to server-side Java. I've been strictly a Java developer for almost...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.