Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile and run java File under linux

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report