Reputation: 1264
In Eclipse, I wrote a Java class Test
with a main()
function.
The project in which is defined the class, I added the jar file bcprov-jdk15on-151.jar
(I am using the library BouncyCastle).
In Eclipse, there is no problem and my program runs normally. But when I try to do it in a terminal, I get an exception.
After checking SO I found a similar post: NoClassDefFoundError while running a java program in terminal from IDE but the solution given doesn't work.
To illustrate my case, in the directory C:\Docs\workspace\Terminal\bin\
I have the file Test.class
. If I run java Test
I get Exception in thread "main" java.lang.NoClassDefFoundError: org.bouncycastle.math.ec.ECFieldElement
.
If I run java -cp bcprov-jdk15on-151.jar Test
(I put the .jar
in the same directory to simplify) I get Error: Could not find or load main class Test
so it seems that the dependency error is solved but another one occurs.
What am I doing wrong? Just to give the structure of my .java
file:
import java.io.*;
...
public class Test {
... local methods ...
public static void main(String[] args) {
...
}
}
Thanks in advance.
Upvotes: 0
Views: 748
Reputation: 748
Try this, you forgot to include current path "."
java -cp ".;bcprov-jdk15on-151.jar" Test
Hope it help
Upvotes: 1