By Jiri Sedlacek-Oracle on Nov 27, 2006
Two weeks ago Sun Microsystems announced opensourcing key Java implementations including javac, the Java programming language compiler. You can get the javac source code also from netbeans.org with a detailed tutorial to getting, building, and running the javac sources in NetBeans IDE.
Since the javac sources are available as NetBeans project inside the IDE, you can easily build and run the compiler as well as investigate how things work inside. For this the Profiler can be also useful showing you the stack traces and other information about compiler's runtime. Just follow these five simple steps to check out how easy is now to profile javac.
- Download and install NetBeans IDE 5.5 and NetBeans Profiler 5.5.
- Follow these instructions to download javac source code and open it as a project in the IDE.
- Create sample J2SE project in the IDE using New Project wizard: category Samples/General, project Anagram Game. For the
following instructions the project is expected to be located in
- Edit the javac buildscript
build.xml: append target
profilefor example below target
- Set javac project as the Main project and invoke the Profile Main Project action. Choose Java platform for profiling
(most likely the Default one) and select the profiling task you want to use. After clicking the Run button the Profiler asks
you to select the ant target for profiling - choose
profilein the combo and click OK.
That's all - now you are profiling compilation of Anagram Game by the javac!Note: The above scenario is for Windows and Anagram Game project. If you want to profile compilation of other project/application on other operating system, you need to modify (some of) following target properties:
app.dir:root directory of profiled project/application
app.mainclassfile:relative path to mainclass java file of profiled project/application
app.srcdir:relative path to profiled project/application source root
app.builddir:relative path to profiled project/application compiled classes root