title: sieving primes up to 10^12
body: <p>I'm working on something that requires me to generate all prime numbers up to 10^12.</p>
  
  <p>Since I have never needed this many primes before, I normally just implement the algorithm on this webpage <a href="http://introcs.cs.princeton.edu/java/14array/PrimeSieve.java.html" rel="nofollow">here</a></p>
  
  <p>The problem here is, of course, that 10^12 is larger than the max value for an integer, and as a result I cannot make an array of that size. </p>
  
  <p>I am unfamiliar with the methods one would use to generate so many primes efficiently, and was wondering if anyone could shed some light on the situation.</p>