• Post Reply Bookmark Topic Watch Topic
  • New Topic

compiling and executing java code at runtime  RSS feed

 
john vikas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
friends,

we are working in a workflow project.
our main goal is to execute a java code given in a text box of a jsp page
dynamically.
the result is to be used later in the further computation.

eg:
<code>
the user will give code in the following way:
he will start the code by opening a braces:
{
int a=10;
int b=10;
int c= a+b;
}
end of java code
</code>
in the above example the user will later might use the value of for decision making. i.e; the value of c depends on the values of 'a' and 'b' which the user gives at runtime.

Limitations:
1)Please avoid the usage of files and streams.

we are waiting for ur advice in this regard as the possible solution for this problem enable us to complete the project

with regards,
johnvikas
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the result is to be used later in the further computation.

What result? Your example has three different local variables. Normally in Java, local variables would be inaccessible outside the block that declares them. If you want these values to be available outside the block, I think you need to decide whether and how data may be passed out of the block. Perhaps with a return statement? Or perhas the block can refer to nonlocal variables from some other context?

You may find it worthwhile to consider a scripting language for these blocks. The most Java-like scripting language I know of is Groovy. There's also Jython, which isn't much like Java, but can easily be invoked from Java.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't post the same question to more than one forum. It just wastes people's time as they repeat what other people have already told you (especially since other people from your class have already asked about this same homework assignment!)

I'm closing this copy and leaving this one open.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!