Issue
first of all, i've searched for some related topics, and already tried the solutions pointed in those, but still have some problems, so i'll try to explain it here hoping for a solution.
I'm trying to compile a java program which's already working on eclipse, on command line. The .jar file and the java files are all in same directory, the class i'm trying to compile is NOT in the .jar, but in this class i used some methods belonging to that .jar (paillier.jar)
I first tried this:
javac -cp paillier.jar CoupleGen.java
java -cp paillier.jar CoupleGen
First line gives CoupleGen.class and no problems for the moment, when i type the second line it gives me the error
Error: Could not find or load main class CoupleGen
So, reading some topics in here i tried another way
javac -cp paillier.jar CoupleGen.java
java -cp .;paillier.jar CoupleGen
and the result is a list of "how-to-use" java command with the end of these lines
paillier.jar command not found
So, i clearly make some mistakes, but actually i can't understand. Just in case it's needed, i set up ambient variable.
Any help is really appreciated.
Cheers
Here's the code i'm trying to compile
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Random;
import paillierp.key.KeyGen;
import paillierp.key.PaillierKey;
import paillierp.key.PaillierPrivateKey;
public class CoupleGen {
public static void main(String[] args) throws IOException{
//Creo un messaggio m da criptare
//for (int j=1; j==2; j++){
int nodeID=5;
int s=32;
Random random = new Random();
long seed = random.nextLong();
PaillierPrivateKey pr= KeyGen.PaillierKey(s, seed);
PaillierKey pu= pr.getPublicKey();
System.out.println("PublicKey:("+pr.getN()+","+pr.getNPlusOne()+")");
String pubkey ="PublicKey"+nodeID;
FileWriter File= new FileWriter(pubkey);
PrintWriter out=new PrintWriter(File);
out.println("n:" + pu.getN());
out.println("n+1:" + pu.getNPlusOne());
out.println("n^s:" + pu.getNS());
out.println("n^s+1:" + pu.getNSPlusOne());
// out.println("rnd:" + pu.getRnd());
out.println("k:" + pu.getK());
out.close();
//} for not working on this pc
}
}
Solution
when you are executing below line, you are getting the below error right ?
javac -cp paillier.jar CoupleGen.java
Error: Could not find or load main class CoupleGen
That means compiler is looking for the CouplenGen.java in paillier.jar. Actually CoupleGen is outside of the jar file.
Answered By - Venkat Kondeti