473,322 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

help needed to find the compile time

How to know how much time taken by jvm to compile the application
Oct 18 '07 #1
8 1920
r035198x
13,262 8TB
How to know how much time taken by jvm to compile the application
The JVM does not compile the application. javac does. The JVM runs the .class files.
Oct 18 '07 #2
JosAH
11,448 Expert 8TB
The JVM does not compile the application. javac does. The JVM runs the .class files.
But Javac itself is entirely written in Java and is run by the JVM as well. As of
Java 1.6 there's a nice interface available to the user, i.e. you can programmatically
start the Javac compiler and time its performance if you like.

kind regards,

Jos
Oct 18 '07 #3
r035198x
13,262 8TB
But Javac itself is entirely written in Java and is run by the JVM as well. As of
Java 1.6 there's a nice interface available to the user, i.e. you can programmatically
start the Javac compiler and time its performance if you like.

kind regards,

Jos
That will be the JavaCompilerTool interface?
Yep, it's quite nice.
Oct 18 '07 #4
JosAH
11,448 Expert 8TB
That will be the JavaCompilerTool interface?
Yep, it's quite nice.
I haven't tried it yet but can we instantiate a compiler object when just the JRE
is installed on some machine? I guess not but can't prove it.

It would be nice to have a 'scriptable' Java, i.e. compile from a String or Stream
to a byte[] array and use that for class loading ... it would make BeanShell
superfluous ;-)

kind regards,

Jos
Oct 18 '07 #5
r035198x
13,262 8TB
I haven't tried it yet but can we instantiate a compiler object when just the JRE
is installed on some machine? I guess not but can't prove it.

It would be nice to have a 'scriptable' Java, i.e. compile from a String or Stream
to a byte[] array and use that for class loading ... it would make BeanShell
superfluous ;-)

kind regards,

Jos
I imagine
Expand|Select|Wrap|Line Numbers
  1. JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
would return null if only there is no javac tool installed.
Oct 18 '07 #6
JosAH
11,448 Expert 8TB
I imagine
Expand|Select|Wrap|Line Numbers
  1. JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
would return null if only there is no javac tool installed.
This is cute; the following prints "null" on my system; (a JDK 1.6 is installed).

Expand|Select|Wrap|Line Numbers
  1. System.out.println(ToolProvider.getSystemJavaCompiler());
  2.  
kind regards,

Jos
Oct 18 '07 #7
r035198x
13,262 8TB
This is cute; the following prints "null" on my system; (a JDK 1.6 is installed).

Expand|Select|Wrap|Line Numbers
  1. System.out.println(ToolProvider.getSystemJavaCompiler());
  2.  
kind regards,

Jos
I found it
Expand|Select|Wrap|Line Numbers
  1. com.sun.tools.javac.api.JavacTool@1ffb8dc
was the output.

I've just been looking at the code for the ToolProvider class. It seems to be checking the System java.home property. I have my Java home pointing to my JDK 1.5_3 but I used NB which I setup to run with 1.6 to run that command.
I wonder which javac it found. The 1.6 or the 1.5 that I use with Eclipse which is also set as my Java home.
Oct 18 '07 #8
JosAH
11,448 Expert 8TB
I found it
Expand|Select|Wrap|Line Numbers
  1. com.sun.tools.javac.api.JavacTool@1ffb8dc
was the output.

I've just been looking at the code for the ToolProvider class. It seems to be checking the System java.home property. I have my Java home pointing to my JDK 1.5_3 but I used NB which I setup to run with 1.6 to run that command.
I wonder which javac it found. The 1.6 or the 1.5 that I use with Eclipse which is also set as my Java home.
I just peeked at the sources of the ToolProvider class too: you're right: it checks
the java_home variable; it it points at the jre it assumes that the jdk is next to it.
Finally it attempts to find the tools.jar where the compiler can be found.

I didn't have any java_home value set, hence the "null" being returned. I find it a bit
of a clumsy mechanism but I'm sure Sun uses a fancy and expensive name for it ;-)

kind regards,

Jos
Oct 18 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: pekka niiranen | last post by:
Hi there, I have perl script that uses dynamically constructed regular in this way: ------perl code starts ---- $result ""; $key = AAA\?01; $key = quotemeta $key; $line = " ...
6
by: Code4u | last post by:
I need to design data storage classes and operators for an image processing system that must support a range of basic data types of different lengths i.e. float, int, char, double. I have a...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
12
by: LongBow | last post by:
Hello all, From doing a google serach in the newsgroups I found out that a string can't be returned from a function, but using a char* I should be able to do it. I have spent most of the day...
6
by: Jax | last post by:
I have Visual Studio 2002 Standard Edition. It has been working fine up to a point and now i'm at that point. Due to the limitations of the edition i am not using any of my own .dll's and instead...
4
by: Chronologic | last post by:
All, I have an issue I would like some expert help on. I understand, or so I believe, that C# does not support the concept of a "compile time macro". At least not in the sense I'm looking...
5
by: Niklas Norrthon | last post by:
I've been banging my head in the wall for some time now over a little problem having to do with partial specialization of function templates. The real problem is more complex than this, but...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: cwoll | last post by:
Hi I need help. I have a ms access 2003 database that I would like to upgrade to ms access 2007. The first time I opened I had to fix a few references it wanted a DAO2535.TLB file witch I gave it,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.