[java] Scripting engine in Java - Do We Really Need Them?

Started by
15 comments, last by GameDev.net 19 years, 1 month ago
Question to Java Guru! Need some lightweidth script engine like lua to embed into java applet and app OR may be java have one ? I know about using javac via System at run time and then loadin via reflection but it is imposible in applet. Realy do I need this stuff ? Just because recompilation less - YES! Found this http://www.beanshell.org comments if any? [Edited by - HellCreator on February 15, 2005 2:33:47 AM]
Can't be root?Reboot!mount -r /home/hell
Advertisement
Well, you never really "need" a scripting engine because it's possible to do anything you can with a scripting engine, with precompiled code.

You might find it advantageous under some circumstances to use a scripting engine though.

Regarding using javac in an applet, no you can't, but you *can* run a server-side script which runs javac and returns the class file(s) (perhaps in a jar).

You should look at Rhino (&#106avascript engine written in Java, uses reflection) to achieve what I think you're trying to.<br><br>Mark
Having scriptable events/code makes the software development cycle easier. You can adjust a script without having to recompile the entire application. Once you have finalised the script you can either hard code it or leave it scripted. Scripting also allows for a lot of extensibility in a system as well.


The best scripting engine I have found for use in Java is Beanshell (which you already found), as it integrates seamlessly.

[edit] spelling
You could try Jython
-LuctusIn the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams
Or you could just use XML. You can store anything you want in XML, so it would be a good replacement for a scripting engine. Plus Java provides an API for loading XML already.
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
Thanks for all replays
I found verry interesting Rhino and Beanshell.
The mission is - do not force the end user to dowload and ah to install libraries required to app or applet and do not doing any server side action because engine may be oriented for runing on client mashine only without installing any servers localy.
Can't be root?Reboot!mount -r /home/hell
Quote:Original post by CaptainJester
Or you could just use XML. You can store anything you want in XML, so it would be a good replacement for a scripting engine. Plus Java provides an API for loading XML already.

but - do java provide proccessing stored data as class object or class function
it is what the scripting do?
Can't be root?Reboot!mount -r /home/hell
Quote:Original post by HellCreator
The mission is - do not force the end user to dowload and ah to install libraries required to app or applet and do not doing any server side action because engine may be oriented for runing on client mashine only without installing any servers localy.

In case you decided against jython because of those reasons you might want to reconsider. Jython doesn't put any prerequisies on client or server, you just have to pack a 700k library together with your app/applet.

Besides, python is an awesome language =)
-LuctusIn the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams
Quote:Original post by HellCreator
but - do java provide proccessing stored data as class object or class function
it is what the scripting do?


I believe you can do that with reflection. However, I am not sure I understand what you are saying. Can you explain a bit more?
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
Don't forget pnuts.

This topic is closed to new replies.

Advertisement