How to know how much time taken by jvm to compile the application
help needed to find the compile time
Collapse
X
-
Tags: None
-
But Javac itself is entirely written in Java and is run by the JVM as well. As ofOriginally posted by r035198xThe JVM does not compile the application. javac does. The JVM runs the .class files.
Java 1.6 there's a nice interface available to the user, i.e. you can programmaticall y
start the Javac compiler and time its performance if you like.
kind regards,
JosComment
-
That will be the JavaCompilerToo l interface?Originally posted by JosAHBut 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 programmaticall y
start the Javac compiler and time its performance if you like.
kind regards,
Jos
Yep, it's quite nice.Comment
-
I haven't tried it yet but can we instantiate a compiler object when just the JREOriginally posted by r035198xThat will be the JavaCompilerToo l interface?
Yep, it's quite nice.
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,
JosComment
-
I imagineOriginally posted by JosAHI 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
[CODE=java]JavaCompiler compiler = ToolProvider.ge tSystemJavaComp iler();[/CODE]
would return null if only there is no javac tool installed.Comment
-
This is cute; the following prints "null" on my system; (a JDK 1.6 is installed).Originally posted by r035198xI imagine
[CODE=java]JavaCompiler compiler = ToolProvider.ge tSystemJavaComp iler();[/CODE]
would return null if only there is no javac tool installed.
[code=java]
System.out.prin tln(ToolProvide r.getSystemJava Compiler());
[/code]
kind regards,
JosComment
-
I found itOriginally posted by JosAHThis is cute; the following prints "null" on my system; (a JDK 1.6 is installed).
[code=java]
System.out.prin tln(ToolProvide r.getSystemJava Compiler());
[/code]
kind regards,
Joswas the output.Code:com.sun.tools.javac.api.JavacTool@1ffb8dc
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.Comment
-
I just peeked at the sources of the ToolProvider class too: you're right: it checksOriginally posted by r035198xI found itwas the output.Code:com.sun.tools.javac.api.JavacTool@1ffb8dc
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.
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,
JosComment
Comment