This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Pre-compiling a script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Pre-compiling a script" Watch "Pre-compiling a script" New topic

Pre-compiling a script

Vinicius Souza
Ranch Hand

Joined: May 18, 2011
Posts: 70

Im creating a program where I need to execute the same script continuously so I was wondering if I can pre compile it ? My code below
package com.xcreator;

Thanks in advance!

Java is the best (I love C too) heehhh
Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

You can compile a script at runtime if the ScriptEngine implements the Compilable interface.
If so, you can cast it to Compilable and invoke either of the compile() methods to obtain a CompiledScript instance, which you can then re-use as often as you like.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
I agree. Here's the link:
subject: Pre-compiling a script
It's not a secret anymore!