Preface
For beginners, they will encounter many difficulties when writing Java code first. Here is a common error, as follows:
Beginners usually start with Hello and World. They are useless and have been very strong. After a long time of bronze drum, they finally need to run javac Hello.java on DOS, an error will be reported: File cannot be found
Solution
To troubleshoot in the following steps:
1. Check whether the environment variables are configured correctly. Output a javac command, which can output help information, indicating that the configuration information is correct (the following figure shows the environment variable configuration, no problem).
2. The environment configuration is correct, and then check whether the path of the executed java file is correct.
3. This is more likely to cause problems. Check whether the Java file extension is .java. If your system folder option hides the extension txt, the file you changed may be Hello.java.txt.
(My previous one was hidden, and I couldn't see .txt and .java in the following two file suffixes)
My computer is a win10 system. The setting method for finding "Hide extensions for known file types" is as follows:
This computer -> File -> Change folders and search options -> View -> Advanced settings -> Hide the extension of known files, check and remove
At this time, you can see if your suffix name is wrong.
If it is not a win10 system, it should be: My computer -> Tools -> Folder Options -> View -> Hide the extension of known file types and check to remove.
After the above investigation, my verification has been successful and may also help you.
Summarize
The above is the entire content of this article. I hope that the content of this article has certain reference value for everyone's study or work. If you have any questions, you can leave a message to communicate. Thank you for your support to Wulin.com.