Home > Java > javaTutorial > How to compile Java

How to compile Java

(*-*)浩
Release: 2020-10-13 10:21:33
Original
32120 people have browsed it

Java compilation will have different solutions according to different situations. Here we will introduce three situations of Java compilation.

If you want to develop Java and compile Java, you must have installed JDK. If not, please follow our Java Tutorial, which will have the answers you want.

How to compile Java

Java compilation method:

First method:

In IDE For example, for Java programs written in eclipse and myexlipse, after executing the save operation shortcut key (ctrl s), eclipse and myeclipse will call javac to compile the program after saving. Although there is no change on the surface at this time, you can check the current In the bin directory of the project.

How to compile Java

You will find that there is a compiled bytecode file in the bin directory of the current project. This is because of the convenience of the IDE tool, which has automatically helped you Compiled.

How to compile Java


##Second type:

As an independent file and does not define Java environment variables. At this time, you will definitely not be able to compile directly in the command line window. You can only enter cmd in the text box in [Start] → [Run] or use the shortcut key (WIn R) to open the command line window. Then switch to the java bin directory through the command line command, and the source files in the folder where the Javac directory is located can compile the program.

For example: javac D:\txt//HelloWorld.java

How to compile Java

The compiled class file will appear in the folder location.

How to compile Java


##Third type:

As an independent file and defines Java environment variables. At this time, you can compile and compile directly in the command line window. You can only enter cmd in the text box in [Start] → [Run]. Or use the shortcut key (WIn R) to open the command line window. Just enter the Javac target source file directly.

Example: Javac HelloWorld. java

How to compile Java#The compiled class file will appear in the folder location.

The above is the detailed content of How to compile Java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template