-2

I crawled through the forums and tried a few things, I am just trying to run a java file I downloaded from github that I did not make. I compiled it fine, but am now stuck. Here's what I've done so far (In the downloads directory for both):

java.Randomizer, and java -cp C:\Users\enajo\Downloads\Randomizer

Both resulted in Error: Could not find or load main class The file is located in downloads and is named Randomizer.class with the classname being ca.pogo4545.randomizer. What am i doing wrong?

Nuwan Alawatta
  • 1,812
  • 21
  • 29
Evan Najor
  • 1
  • 1
  • 1
  • Questions: what is the fully qualified class name of the class you want to run? Does it have a main method entry point? What dependencies does it have? You may not be able to run it at all, if it has dependencies. And you'll have to ensure that the class is in the right directory structure to match its package name. – ManoDestra Jul 10 '18 at 13:53
  • Try running javap against it to see its package and available methods e.g. javap /path/to/your/Randomizer.class. – ManoDestra Jul 10 '18 at 13:55

2 Answers2

0

If you declared a package name (that you mentioned as classname) the run command line must include the name of it:

java ca.pogo4545.randomizer.Randomizer

But in this case the file also must be in a directory structure that represent the same package, and if you using more than one class you must include the -cp arguments

Marcos Vasconcelos
  • 18,136
  • 30
  • 106
  • 167
0

First of all the name of the class must be the same as the name of the file . Java and Javac are case-sensitive.

Compile like : javac HelloWorldApp.java

And run like : java -cp . HelloWorldApp