The first step is, if there is a folder named Java in the e drive, and there is a pre-written .java program in the Java folder, as follows:
The second step is to press the "Windows R" key to open the run, enter "cmd" to open the command line window, as follows:
#The third step is to go to the folder where the HelloWorld.java file is located.
(1) The file is on drive E. First enter e: and press Enter.
(2) Enter cd Java to enter the Java folder.
(3) Enter javac HelloWorld.java and press Enter.
At this time, in the Java folder, a .class bytecode file with the same name as the .java file is generated.
(4) Enter java HelloWorld to run the Java virtual machine running program. The Java virtual machine first loads the compiled bytecode file (.class file) into the memory. This The process is called class loading, which is completed by the class loader. Then the virtual machine interprets and executes the Java class loaded into the memory, and you can see the running results.
Java programs are interpreted and executed by the virtual machine, not the operating system. The advantage of this is that it can achieve cross-platform performance, which means that the same program can be written for different operating systems, and only different versions of virtual machines need to be installed. This approach enables the Java language to "write once, run anywhere", effectively solving the problem of programming languages generating different machine codes when compiled on different operating systems, and greatly reducing the cost of program development and maintenance. .
But it is worth noting that Java programs can achieve cross-platform features through the Java virtual machine, but the Java virtual machine is not cross-platform. In other words, Java virtual machines on different operating systems are different.
Compilation and execution completed.
php Chinese website, a large number of free Java introductory tutorials, welcome to learn online!
The above is the detailed content of How to run .java files. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment
