I am trying to run a java code in command prompt. I have the java file in a folder abc in D drive. I have 2 jars also in the same folder. Compilation is done. Class file is created within the folder abc. When trying to execute it using java command, I am getting error "could not find or load main class". Could someone please help me? I am using the below command in cmd: java -cp D:/Java_mail/javax.mail.jar;D:/Java_mail/activation.jar Emailfetch
Asked
Active
Viewed 57 times
-1
-
use `java -jar` – Lino Aug 10 '18 at 12:02
-
2Add content, of your class that contains the "public static main" method. – Simion Aug 10 '18 at 12:02
-
@Lino could you please elaborate? – Devjith Aug 10 '18 at 12:05
-
Perhaps this helps? https://stackoverflow.com/questions/5757189/how-do-i-run-java-class-files – DodgyCodeException Aug 10 '18 at 12:57
1 Answers
0
To be able to run a JAR file, you must have your jar as runnable. It means you must have a class in it that has
public static void main(String[] args)
https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html
Otherwise you will not be able to run it.

Simion
- 353
- 1
- 9