How to compile and run java File under linux
This article mainly explains the "java file how to compile and run under linux", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "java file how to compile and run under linux" bar!
The command javac compiles and runs the corresponding java file.
For example: javac xxx.java will generate xxx.class in the current directory and then java xxx can run
But what if the running class references another external class?
For example, if there are objects referencing Test02.java in Test01.java, you need to compile the Test02.java command javac Test02.java first, then exit outside the package after compilation, and then compile the Test01.java class command javac-cp. Com/xxx/yyy/Test01.java, and then java com.xxx.yyy.Test01 can run.
As shown in the figure: there are Test01.java and Test02.java under the corresponding package path, and Test02 is referenced in the Test01.java code.
Compiling Test02.java first generates the Test02.class class file in the current directory.
Return to the outer layer of the packet to execute javac-cp. Com/xxx/yyy/Test01.java to compile the Test01.java file
Finally, execute java com.xxx.yyy.Test01 and run it.
Thank you for reading, these are the contents of "how to compile and run java files under linux". After the study of this article, I believe you have a deeper understanding of how to compile and run java files under linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!