File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes using javac.Main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "using javac.Main" Watch "using javac.Main" New topic

using javac.Main

Sandeep Lakshmipathy
Ranch Hand

Joined: Mar 05, 2002
Posts: 31
I have written a program that asks the user for a java file name and will compile it on the fly using a call to compile() method in the package and class Main. If i am using the IBM jdk, or any other jdk, will this package be a part of it? The bigger question is, Is there a standard way of compiling classes on the fly?
Can we use the Compiler class for this purpose?

Sandeep Lakshmipathy

Joined: Apr 10, 2002
Posts: 4
On the fly compilation can be done but is never recommended as there might be compilation problems. Yuo could use the Runtime class to compile your class for you.

Sahil G<p>NY
Sandeep Lakshmipathy
Ranch Hand

Joined: Mar 05, 2002
Posts: 31
I do not want to use the process class. and i want to compile using the method calls. also, if the user has jre installed on his machine, my code using Process class and javac will not work.
Matt Siegel
Ranch Hand

Joined: Jul 18, 2000
Posts: 55
Either . . .
1. Do not use another JDK
2. Always have the jar file that contains Sun's tools.
[ April 11, 2002: Message edited by: Matt Siegel ]
I agree. Here's the link:
subject: using javac.Main
It's not a secret anymore!