non-static method generatePublic(KeySpec) cannot be referenced from a static context
<p>I am getting the above error in this particular line of code:  </p>

<pre><code>KeyFactory keyFactory=keyFactory.getInstance(keyAlgorithm);

        EncodedKeySpec privateKeySpec=new PKCS8EncodedKeySpec(privateKeyBytes);
        PrivateKey privateKey1=keyFactory.generatePrivate(privateKeySpec); 
</code></pre>

<p>To be precise this is the error I get:  </p>

<pre><code>GeneratePublicPrivateKeys.java:35: error: non-static method generatePublic(KeySp
ec) cannot be referenced from a static context
PublicKey publicKey1=KeyFactory.generatePublic(publicKey
Spec);
</code></pre>

<p>Note: I have gone through these posts<br>
<a href="http://stackoverflow.com/questions/4922145/non-static-method-cannot-be-referenced-from-a-static-context-error">“Non-static method cannot be referenced from a static context” error</a><br>
<a href="http://stackoverflow.com/questions/2694566/non-static-method-cannot-be-referenced-from-a-static-context">non static method cannot be referenced from a static context</a><br>
and some more and I have tried the solutions provided there,but no they do not solve my problem  </p>

<p>What should I do?<br>
Thankyou in advance:)</p>
