-1

I have copied the jar file downloaded from the site to the Java built path. Still I get this error.

Error: Could not find or load main class bouncy

All my program does is to verify addition.

 import java.security.*;
    import org.bouncycastle.jce.provider.BouncyCastleProvider;
    public class bouncy {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        java.security.Security.addProvider(new BouncyCastleProvider());
        //Security.addProvider(new BouncyCastleProvider()); 
        System.out.println("This works");

    }

      }

Any help?

user1411601
  • 23
  • 2
  • 8

2 Answers2

1

In eclipse:

Right click on your project -> Build path-> configure build path -> order and export see if your jar there and check.

For run your appliaction:

Right click on "bouncy" class -> run as -> java application.

gran33
  • 12,421
  • 9
  • 48
  • 76
  • sure you've been there already, but just in case, take a look at:http://stackoverflow.com/questions/7485670/error-could-not-find-or-load-main-class – gran33 May 23 '13 at 12:40
  • One more when I add the jar file, there is a red exclamation mark against the project and goes off when I remove it...and file I am trying to add is bcprov-jdk15on-148.jar...Am I doing something wrong? – user1411601 May 23 '13 at 14:46
  • Don't forget to clean the project before add/change jar files. – gran33 May 23 '13 at 14:50
  • Can you add the error log when you get the red exclamation mark? – gran33 May 23 '13 at 14:51
  • ok, I removed the jar file and added it again. There were two jars and one with 'ext' on its name, I kicked it out...I do not have exclamation mark now...The code compiles and it says the Bouncy Castle provider not available...when the folllowing code is compiles.. – user1411601 May 23 '13 at 15:31
  • import java.security.Security; public class Main { public static void main(String[] args) { //BC is the ID for the Bouncy Castle provider; if (Security.getProvider("BC") == null){ System.out.println("Bouncy Castle provider is NOT available"); } else{ System.out.println("Bouncy Castle provider is available"); } } } – user1411601 May 23 '13 at 15:31
0

Your original error shows that Eclipse does not even find your main class. This is because your code did not build (because of the "red exclamation mark"). If your class is not generated it cannot be loaded by the classloader, and Eclipse can of course not execute your main method if you do.

So the only answer we can give to your current question is that you will have to build your project first, and then execute the original contents of your main method, instead the one you gave in the comments.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
  • Yep, thats what I did it is not saying "Bouncy Castle provider is NOT available". I think now the problem is different – user1411601 May 24 '13 at 12:21