wood burning stoves 2.0*
The moose likes Java in General and the fly likes Javac api Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Javac api" Watch "Javac api" New topic
Author

Javac api

Ranganath Junpal
Ranch Hand

Joined: Aug 31, 2006
Posts: 76
Hi all,
Can some one explain how to use the com.sun.tools.javac api with some examples.. I did bit of google but could not get much resources out of it. the api is of jdk1.5 not 1.6..

Regards
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Follow this link:
http://www.javaworld.com/javatips/jw-javatip131.html

However, i would like to know as to why you need this class but for some jazz to show off


apigee, a better way to API!
Ranganath Junpal
Ranch Hand

Joined: Aug 31, 2006
Posts: 76
sorry its not for show off.. i am building an tool for which this api is very much needed.. anyways thanks for the url.
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Hey, sorry for the last comment. That was not meant to hurt.
But it sounds interesting to me, so it will be great if you can tell me the scenario.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41110
    
  45
Using javac programmatically can come in handy for various purposes. I'm using it in a piece of code where a user can enter mathematical formulas. Instead of trying to interpret those, I'm wrapping them inside a Java class, and load the class dynamically. That eventually produces native code, and is much faster than anything I could code up to interpret those formulas.


Ping & DNS - my free Android networking tools app
Ranganath Junpal
Ranch Hand

Joined: Aug 31, 2006
Posts: 76
Basically we are using it for an online labs(virtual labs).. like we are building a website where in people can learn about the language like java, jython online and experiment there programs in these virtual labs N forums. Its basically for people whos is enthusiastic about the technology but not able to afford to have a pc and other resources to learn. This website is reachable to them at the cost of just 10-15 bucks per hour (in India) to browse through and learn these technologies..
So i wanted to get familiar with this api before i go ahead with the design and understand the api..

Regards
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Hey thanks Ulf & Ranganath, i never knew that people used this class. Thanks for the enlightment
Ranganath Junpal
Ranch Hand

Joined: Aug 31, 2006
Posts: 76
hi all,

Actually the url did help to get some idea bout the javac api. now i used this Main class of javac and used Main.compile(args) method. now i need to redirect the output to text area. please let me know how to go about this in javac api..

Thank you
Ranganath Junpal
Ranch Hand

Joined: Aug 31, 2006
Posts: 76
hi all,

Actually the url did help to get some idea bout the javac api. now i used this Main class of javac and used Main.compile(args) method. now i need to redirect the output to text area. please let me know how to go about this in javac api..

Thank you
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

You can use the overloaded form of compile method that takes a PrintWriter.
This writer points to the stream where the output is to be printed.
Ranganath Junpal
Ranch Hand

Joined: Aug 31, 2006
Posts: 76
cool, i was trying it.. thanks a lot.. good to know i am on a right track..
 
wood burning stoves
 
subject: Javac api
 
Similar Threads
(J2ME) : To display HTML code in Midlet
web.xml parameters?
J2ME
Pivot axis
Creating Tabs in JSP using xml file