This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using javac.Main

 
Sandeep Lakshmipathy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 com.sun.tools.javac 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?
Thanks
 
sandyboy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
HTH
 
Sandeep Lakshmipathy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either . . .
1. Do not use another JDK
or
2. Always have the jar file that contains Sun's tools.
[ April 11, 2002: Message edited by: Matt Siegel ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic