Java as a scripting language.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • William Korvine

    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.Functio ns.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

    #2
    Re: Java as a scripting language.

    William Korvine wrote:[color=blue]
    > 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:[/color]
    [snip][color=blue]
    > I would like similer code to work in Java, but I can't
    > find if it's possible to expose these objects to Java.[/color]

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

    --
    Jonas Kongslund

    Comment

    • FISH

      #3
      Re: Java as a scripting language.

      William Korvine <korvine@hotmai l.com> wrote in message news:<Xns94389E 29FC644korvineh [email protected] 5.95.104>...

      [snipped...]
      [color=blue]
      > 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.[/color]

      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!)

      The MDN Web Docs site provides information about Open Web technologies including HTML, CSS, and APIs for both Web sites and progressive web apps.


      -FISH- ><>

      Comment

      Working...