How to compile and run java files using command line

I believe that everyone is generally using the IDE environment to develop and run java files, but I think it is possible to simply run java files in the command line, and the skills are not overwhelming.

Next, let me talk about compiling and running java files:

  1. The first step is to start the next entry program ( note: the class name in the program must be the same as the name of the saved file )
  2.  

  3. The second step, enter the directory where the java file is saved ( note: you must enter the saved directory, otherwise an error will occur )
  4. The fourth step uses javac HelloWorld.java to compile the source program to generate a .class intermediate code
  5. The fifth step is to use java HelloWorld to run the program ( note that you do not need to write .class at the end of the program after java )
  6.  

  7.  

     

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325087928&siteId=291194637