Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
compile directive for conditional compile for Java 1.4 versus Java 5
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="timjowers, post: 2954272"] Does a way exist to instruct the Java compiler to compile code only if a certain version of Java is supported? For example, I may want to measure with milliseconds in Java 1.4 or nanoseconds if I'm running in Java 5. import java.io.IOException; public class JVMLoadTimeRunner { public static void main(String[] args) { long start = System.currentTimeMillis(); // only compile this line in Java 1.4 //long start = System.nanoTime(); // only compile this line in Java 5 try { Process newP = Runtime.getRuntime().exec( cmd ); newP.waitFor(); long end = System.currentTimeMillis(); System.out.println( "Process Execution took " + (float)(end-start)/ 1000F + " seconds" ); // Java 5 // System.out.println( "Process Execution took " + (float)(end- start)/1000000000F + " seconds" ); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { System.out.println( "Process wait threw an Exception" ); e.printStackTrace(); } } } [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
compile directive for conditional compile for Java 1.4 versus Java 5
Top