search
HomeJavaJavagetting StartedHow to run .java files

How to run .java files

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:

How to run .java files

How to run .java files

The second step is to press the "Windows R" key to open the run, enter "cmd" to open the command line window, as follows:

How to run .java files

How to run .java files

#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.

How to run .java files

(2) Enter cd Java to enter the Java folder.

How to run .java files

(3) Enter javac HelloWorld.java and press Enter.

How to run .java files

At this time, in the Java folder, a .class bytecode file with the same name as the .java file is generated.

How to run .java files

(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.

How to run .java files

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MantisBT

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

Zend Studio 13.0.1

Powerful PHP integrated development environment