Originally posted by Santiago Bravo:
...I can compile the file as:
javac Java/packages/readPackage/red.java
and run it as:
java -cp Java/packages readPackage.red
But how do I compile with the -cp or -classpath flag? ...
Note that when a class is declared to be part of a package, the
qualified name of the class is packageName.ClassName, and its location (classpath) is the
parent directory of "packageName." This is why you run your packaged class using...
java -cp Java/packages readPackage.red
Specifying a classpath for compilation is no different.
If your file is compiling correctly without an explicit classpath, then you do not need to specify one. (Note that without an explicit classpath, Java's default is to look in the current directory.) Otherwise, you need to ask yourself: What classes outside of Java's core API are required for your source file to compile? And where are these? It looks to me like they would probably be under Java/packages.