title: Generating Random Long value in Java
body: <p>I am trying to generate two  9 digit long random long value in Java using the below code:</p>
  
  <pre><code>for (int i =0;i&lt;2;i++) {                
      String axisIdStr = Long.toString((long)(System.nanoTime() * (Math.random() * 1000)));
      System.out.println("@@@@@@@@ axisIdStr "+axisIdStr);
      String axId = axisIdStr.substring((axisIdStr.length() -9), axisIdStr.length()) ;
  }
  </code></pre>
  
  <p>But when I run this in windows, i get two different numbers where as when run in mac, I get same two numbers. Why is this happening ?
  Can you suggest a better way to generate the long values?</p>