Create MyApp.java in java_lessons / com / dot / myapp
.
Create Practice.java
by copying MyApp.java.
Write what you want to try in Practice.java.
I put the outer class of MyApp.java in java_lessons / com / dot / myapp / model
and loaded it, but I want to try a simple code without loading the outer class, so I removed package and import I created Practice.java.
And the compilation went well, but I can't run it.
When trying to run
In a loop with the error Main class com.dot.myapp.Practice was not found or could not be loaded
.
When I looked it up, I managed to write the PATH, but I created a test directory separately from the java_lessons directory, moved Practice.java to it, and compiled and executed it.
I thought that it might be something about PATH.
But I don't know what to do.
Hmm, what should I do when I say this? I wish there was someone who could ask questions, but I'm not self-taught! You can ask on the net, but then I want to deal with it myself!
If you can list some possible causes for the time being, if you look into each cause, you should be caught in the search with similar error messages! !!
It was deep in the hierarchy of java_lessons, but first create another directory and move it.
harvest Just move to the terminal and then run.
However, the original MyApp could be done deep in the hierarchy, right?
So there is a way to do it without having to go to the terminal and then run it.
So
I don't use the package, but let's declare the package for the time being!
package com.dot.myapp;
With this at the beginning, the first directory, that is,
Return Practice.java to java_lessons / com / dot / myapp
and compile.
I got it.
harvest If you declare a package, you can execute it even if you are deep in the hierarchy. But do I have to write the class in the directory model one level below even though I'm not using it?
Experiment by moving the file again here.
Move to java_lessons / com
, declarepackage com;
and execute.
did it
harvest If it's below the directory where the terminal is located, write the directory for that file in the package declaration!
I think that packaging is a method to manage files with only function and define in model in PHP, but when executing it, it is necessary to write it when it is under the directory where the terminal is located. thing.
After listing some causes, I happened to find a solution at the beginning, but I wonder if it's quick to actually try various things anyway.
Even if you search for the error message as it is, it may get stuck, but it is better to think about it yourself, try it, and solve it.
Deepening your understanding makes it easier to list possible causes, if not in the same situation, in similar situations, resulting in faster resolution!
Anyway, let's think for ourselves and solve it by ourselves to speed up!
Recommended Posts