Here is the code for the main class and the BST class
And this is the compilation error that appears to me, does anyone know what happens?
It happens that when the structure of package
is used the form of compilation / execution changes substantially, a little nothing else.
The JVM
needs to know what is that package where the files of bytecode
are found (compiled classes) and also where the source code src
are.
In this particular case you should not have problems writing the compilation like this:
$ javac -d ~/Desktop/Examples ~/Desktop/Examples/*/*.java
and the execution of this form:
$ java ArbolesBinarios/Main
All of the above no matter where you are , will run from any location.
There are several inaccuracies there:
1st . The folder of your project is
ArbolesBinarios
, a package is used to store within the project folder, a set of classes that have some relationship. So far, when you compile your program, go to the project folder, then look for the package ( folder at the physical level)ArbolesBinarios
and it really is not. BecauseArbolesBinarios
is the project folder, not the package.2nd . To compile, located in the directory of our project, we must compile like this:
javac fuente1.java paquete\fuente2.java paquete\subpaquete\fuente3.java
that is, we must compile from the directory of our project and we must put, if necessary, the path to get from there to the sources. This will generate the files
fuente1.class
,paquete\fuente2.class
andpaquete\subpaquete\fuente3.class
If you do not have much knowledge about Java, it is advisable that you do not compile from the console and do it through an IDE. Since it requires high knowledge about how the compiler will leave the resulting .class
files and you will need to know how to leave the structure of folders and packages in an orderly manner.
The same thing happens with the debugger that Java incorporates.