Saturday, August 15, 2009

Great Quotes

From Troy modified a little bit
  • Original :: Honor you gods, Love you woman, defend your country "Achilles"
  • my version :: Honor you God, Love you women, defend your Religion,family
  • All that is necessary for the triumph of evil is that good men do nothing "Edmund Burke"
  • The price of greatness is responsibility "Winston S. Churchill"
  • I would rather live a short life of glory than a long one of obscurity "Alexander The Great"
  • Those who vote decide nothing. Those who count the vote decide everything "Joseph Stalin"
  • No one's a virgin, life screws us all! "AJ McLean"
  • Sex isn't the answer. Sex is the question, yes is the answer "AJ McLean"
  • Failure is an option, fear is not. "James Cameron"
  • No Retreat, No Surrender. "movie 300"
  • No Woman No Cry . "Bob marley"
  • Good artists copy, great artists steal "Picasso"

Monday, August 10, 2009

Evaluating JavaScript from Java

To evaluate some JavaScript code in java, you have to do the following
  1. Create instance of type ScriptEngineManager
  2. Get JavaScript engine instance by called getEngineByName method
  3. Us e the eval method to evaluate your javascript code
Sample Code


ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("js");
engine.eval("var x = 5;var y = x + 2");