• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

invoke java compiler within tomcats

is it possible to call the java compiler from within a jsp page within tomcats.  i have a program that generates random java code and i would like to compile this code and write the results to a text file?
0
donnae
Asked:
donnae
  • 3
  • 2
  • 2
  • +1
1 Solution
 
CEHJCommented:
Theoretically yes (since your jsps themselves need to be compiled) but make sure you have security permissions to do so and ensure that tools.jar is in the classpath
0
 
CEHJCommented:
Call

com.sun.tools.javac.main.Main
0
 
objectsCommented:
following articles covers what u need to do

http://www.javaworld.com/javatips/jw-javatip131.html
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Mayank SAssociate Director - Product EngineeringCommented:
>> i have a program that generates random java code and i would like to compile this code

Does the code keep changing? If not, then why do you want to compile it? You can simply run it/ call it and get the random numbers which it generates.
0
 
donnaeAuthor Commented:
the reason i want this code to be compiled is that this is a quiz and the user will be asked a question and asked to pick an answer therefore the code must be compiled before hand to know what the result will be
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Ideally the questions and answers should be stored somewhere else like a database/ file and the code just pick up a question randomly from there if that is what is required.
0
 
donnaeAuthor Commented:
The code is generated randomly from an xml file therefore i do not know what the result will be.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
And the code contains questions/ answers? They should be in the XML or database I guess.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now