This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
To compile both .java files I navigate to the correct folder in command prompt (Tomcat Root/mypackage) then ...
You shouldn't put your source code inside Any application server instead have a different place for your development code. Something like "/home/<username>/Dev/.... Then once you compiled and packaged you may move the final product in to the Tomcat (or any other server).
And you seems to have put all the things directly inside Tomcat root (ROOT)? Then have your own context ( or application folder) like "MyTestApp"...
@Ed Ward, checked the first point and that was a typo on my part whilst posting the question.
Then with regards to compiling the different way, that has worked. Why was the previous way I was doing it not working? My understanding of the command that I was using was that it is just a normal compile, but it places the .class files automatically in their directories?
@Vijitha Kumara, I have placed all of my files inside my package, which is inside the Tomcat Root. This is just on my local machine and not anywhere live, although I should get into the good practice of placing things in their correct places :-)
Thanks everyone for the help in such a fast time, it is much appreciated.
My understanding of the command that I was using was that it is just a normal compile, but it places the .class files automatically in their directories?
When you compile the second source file inside the package directory javac would not be able to find the other class file which is required in order for a successful compile, as it start looking a directory named "mypackage" inside "mypackage" unless you specify classpath option which points to the place where you have the class file.