By Devjith


2018-08-10 12:00:36 8 Comments

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

1 comments

@Simion 2018-08-10 12:05:55

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.

Related Questions

Sponsored Content

41 Answered Questions

[SOLVED] What does "Could not find or load main class" mean?

  • 2013-08-07 03:02:46
  • Stephen C
  • 1941247 View
  • 975 Score
  • 41 Answer
  • Tags:   java class main

32 Answered Questions

[SOLVED] Can't execute jar- file: "no main manifest attribute"

40 Answered Questions

[SOLVED] Eclipse "Error: Could not find or load main class"

39 Answered Questions

[SOLVED] Can't start Eclipse - Java was started but returned exit code=13

0 Answered Questions

14 Answered Questions

[SOLVED] Where is Java Installed on Mac OS X?

  • 2013-04-05 04:58:29
  • Thunderforge
  • 515836 View
  • 591 Score
  • 14 Answer
  • Tags:   java macos

2 Answered Questions

Error: Could not find or load main class Test in command prompt

  • 2017-10-27 02:47:37
  • Rathna
  • 734 View
  • 0 Score
  • 2 Answer
  • Tags:   java class main

22 Answered Questions

[SOLVED] Error: Could not find or load main class

  • 2011-09-20 13:10:12
  • Dave
  • 1240875 View
  • 317 Score
  • 22 Answer
  • Tags:   java linux

2 Answered Questions

[SOLVED] Can't seem to resolve the error "Could not find or load main class”

  • 2017-03-12 16:40:59
  • Alexandre Blanchet
  • 231 View
  • 1 Score
  • 2 Answer
  • Tags:   java cmd

0 Answered Questions

Sponsored Content