• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compiling and executing java code at runtime

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It's a tiny ad. At least, that's what she said.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic