Compiling Java scripts in programs

I have a Java program and I want to be able to use Java as a a scripting language in my program.
I want to be able to inherit from a class in my program to create a new class and load it into my program.

I’ve searched Google about this and I don’t believe I’m using the appropriate keywords, because all I get are JIT articles.

These threads will probably help:

This one ends up talking about BeanShell which would do what you ask - http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=cluebies;action=display;num=1109875977

And this one shows how to compile code progmatically:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=2D;action=display;num=1111533366

Kev

Thank you, the 2nd thread had what I was looking for.
Personally I avoid Beans like the plague.

[quote]These threads will probably help:

This one ends up talking about BeanShell which would do what you ask - http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=cluebies;action=display;num=1109875977

And this one shows how to compile code progmatically:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=2D;action=display;num=1111533366

Kev
[/quote]

[quote]Thank you, the 2nd thread had what I was looking for.
Personally I avoid Beans like the plague.
[/quote]
You need to actually read the thread; beanshell has nothing at all to do with javabeans.

/me suspects it was named beanshell so that it would abbreviate to bsh

I started the first thread and got some great advice and actually using both sets of advice…anyway…beanshell turned out to be fantastic so far.

I think you’re right. :slight_smile:
http://www.beanshell.org/intro.html

Looks really good.

long link

There are some articles about NetRexx, Nice, Rhino, JRuby, Groovy and Jython.

And there is also BeanShell and janino.

Here is a pretty recent (March 14, 2005) article:
http://www.javaworld.com/javaworld/jw-03-2005/jw-0314-scripting.html

After at short chat with Mazon I gave Groovy a try… it’s nice that you can compile down to class files, but the classes are a bit cluttered with junk and you need to ship some files of the package either way (dunno exactly which ones).

Well, I settled with beanshell. It does what I want and I can turn it rather easly into usual code at the end.

You could also look at IBM’s Jikes. It claims to be a fast compiler and is now open source.

http://sourceforge.net/projects/jikes/