Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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 ]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic