-1

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

4
  • use java -jar Commented Aug 10, 2018 at 12:02
  • 2
    Add content, of your class that contains the "public static main" method. Commented Aug 10, 2018 at 12:02
  • @Lino could you please elaborate? Commented Aug 10, 2018 at 12:05
  • Perhaps this helps? stackoverflow.com/questions/5757189/… Commented Aug 10, 2018 at 12:57

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.