The moose likes Java in General and the fly likes Controlling Java Compiler by Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Controlling Java Compiler by Program" Watch "Controlling Java Compiler by Program" New topic

Controlling Java Compiler by Program

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
I want to dynamically generate java source files and compile them into .class files for users to download. Is there any way to programmatically control the jdk compiler? I know Tomcat is able to compile JSP into class files dynamically. How does it do this?
Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

There is an existing service that does this ->

You may invoke the javac command through the ProcessBuilder or use the JavaCompiler API to do this. Is this for a class project or something ?

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
I agree. Here's the link:
subject: Controlling Java Compiler by Program
It's not a secret anymore!