title: Generating a random hex string (of length 50) in Java ME/J2ME
body: <p>My app needs to generate a hex string to use as a session ID. Java's <code>SecureRandom</code> doesn't seem to be working ("java/lang/NoClassDefFoundError: java/security/SecureRandom: Cannot create class in system package")</p>
  
  <p>I thought of doing something like this:</p>
  
  <pre><code>byte[]  resBuf = new byte[50];
  new Random().nextBytes(resBuf);
  String  resStr = new String(Hex.encode(resBuf));
  </code></pre>
  
  <p>But the method <code>nextBytes(byte[] bytes)</code> isn't available for some strange reason.</p>
  
  <p>Does anyone have a means of generating a random hex number in Java ME/J2ME?</p>
  
  <p>Many thanks.</p>
  
  <p><strong>Edit:</strong> The above generator seems to work when using Bouncy Castle lcrypto-j2me-145 (but not lcrypto-j2me-147).</p>