Operating System - HP-UX
1832302 Members
2105 Online
110041 Solutions
New Discussion

java.security.ProviderException: setSeed() failed

 
Moiz Khambaty
Occasional Contributor

java.security.ProviderException: setSeed() failed

Hi i have written following code, and compiled using 'javac testc.java'
It got compiled succefully.
But when we are trying to run that its giving Error as shown after my program.
Please note:
when i run it using command 'java -cp . testc'
its giving problem, But if i am executing it using 'java -Djava.security.egd=/dev/random -cp . testc' it Succefully executing.
=======================================
import java.io.*;
import java.util.Properties;
import java.util.Vector;
import java.net.*;
import java.security.SecureRandom;

public class testc {

public static void main(String args[]){

SecureRandom secureRandom = new SecureRandom();
secureRandom.setSeed(System.currentTimeMillis());
System.out.println("Executed Successfully");
}
}
==============================
Error on Execution::
==============================
jeshp01 >java -cp . testc
Exception in thread "main" java.security.ProviderException: setSeed() failed
at sun.security.provider.NativePRNG$RandomIO.implSetSeed(NativePRNG.java:223)
at sun.security.provider.NativePRNG$RandomIO.access$100(NativePRNG.java:108)
at sun.security.provider.NativePRNG.engineSetSeed(NativePRNG.java:92)
at java.security.SecureRandom.setSeed(SecureRandom.java:400)
at testc.main(testc.java:12)
Caused by: java.io.IOException: No such device
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:247)
at sun.security.provider.NativePRNG$RandomIO.implSetSeed(NativePRNG.java:221)
... 4 more
===========================================

Now my question is how i can run this program without using option
"-Djava.security.egd=/dev/random" ???????? Is there any way so that we can change in code to make it work without using above option.