2

I am trying to run a java program on command line, but I keep getting the error message:

Could not find or load main class AnnualExam

I tried all this and still could not find or load class

java -classpath "C:\jcodes\dev\ocpPrep\chapter1OCA\javaBasics" com.university.AnnualExam 

from

/c/jcodes/dev/ocpPrep/chapter1OCA/javaBasics

Here is the code

class AnnualExam {
    public static void main(String  args[]){
        System.out.print("Hello word");
}

enter image description here

  • Possible duplicate of [What does "Could not find or load main class" mean?](https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean) – suvojit_007 Nov 17 '18 at 08:54
  • 1
    Possible duplicate of [Including jars in classpath on commandline (javac or apt)](https://stackoverflow.com/questions/2096283/including-jars-in-classpath-on-commandline-javac-or-apt) – l'L'l Nov 17 '18 at 08:56
  • try this C:\jcodes\dev\ocpPrep\chapter1OCA\javaBasics\com\university\AnnualExam – Gaurav Bahadur Nov 17 '18 at 09:10
  • @GauravBahadur, it is still the same thing. Am still not getting it please help – Oluwatobi Adenekan Nov 17 '18 at 09:26
  • 2
    How does your AnnualExam class looks like, does it have the correct package? Does it provide a Main method? – triplem Nov 17 '18 at 10:27
  • @OluwatobiAdenekan Please edit your question to include the full source code of the `AnnualExam` class. Also write the full error message you get when you try to run the application. – Progman Nov 17 '18 at 14:01
  • I have done that. Thanks – Oluwatobi Adenekan Nov 17 '18 at 19:33

0 Answers0