I don't know your setup, but I can try to explain in my words, so you could try to re-assemble problem solution on your side.
Let's go from the beginning.
There is a file system's directory structure and Java's package structure. That's one. Note, structure I've made it slightly more complicated than it actually could be.
Second is, that to an end-user they both look the same (and in fact they are), if you open some file explorer and look to two let's say directories "aa" and "bb", you couldn't say if one of these directories play any role in an existing (any) Java source file.
Let's say currently you are in the directory "Documents" (navigated through either command-prompt in case of Windows, or terminal in case of UNIX flavour system) and you have such setup:
Class A looks like:
Class B looks like:
So, what is important to know. You have at the moment only source files, you don't have them compiled yet. As you see, class A doesn't appear to be in any user's defined package (so it is in default/no-named package). Contrary wise, class B is in a package io.github.liutaurasvilda
Remember from earlier, that Java package and file system's directory looks same if we were to talk about the directories (or for other people maybe easier to understand - folders).
And if you look once again now how the source files are located in the file system currently, you'd notice, that there is missing mentioned part "io.github.liutaurasvilda", this is what class B has as its package.
So, after you compile your B class's source file "B.java", your compiled file "B.class" must reside in:
or if you look at it as tree structure in your head (ellipsis mean "could be anything"):
Now. The classpath is, where to look for *.class files EXCEPT its package structure. That means that Java knows how to find class files once you show to it, where classes package is located.
So let's assume I compiled my both classes, class A has no package statement, class B has as specified above, so I currently am in the Documents directory, so what I supposed to end up with is:
When you compile classes which contain package statements, you can tell compiler to create packaging structure if it doesn't exist on file system already, and that could be done as next..
In case you are in Documents direcotry:
javac -d temp temp/B.java
In case you are in Documents/temp directory:
javac -d . B.java
(note: . means present working directory)
Once you do that, in your directory Documents/temp the directories /io/github/liutaurasvilda appear along with B.class file inside.
So, you got compiled all stuff and once again, you have:
Now you want to run Java program which's starting point is class A. How you do that. Currently you are in directory Documents.
; <-- classpath separator in Windows
: <-- classpath separator in UNIX flavour OS
The . means, that look for classes in present working directory (meaning in /Documents), and temp means, that look for classes in /Documents/temp, documents get assumed because you are in Documents when issuing such compile instruction.
In case class A also had package statement let's say liu.test, then in an execution instruction you'd need specify class name along with package name, such as:
If you can't re-assemble solution, please show exact structure where your files reside and please show us what instruction you issue from your command-prompt.