• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

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