Home > Java > javaTutorial > body text

How to use java

angryTom
Release: 2019-08-12 09:30:43
Original
22599 people have browsed it

How to use java

This time I will talk to you about how to use Java after installation. I was confused when I first came into contact with Java. I thought that I could start Java programming directly after installing the Java software. In fact, otherwise, I had to set up small development conditions.

Recommended tutorial: Java introductory video tutorial

1. First install jdk

Let me explain here first, only installing Java cannot compile and execute Java programs, so we actually install jdk, and installing java is just to install jre (Java runtime environment).

I believe everyone knows that jdk is the core of Java.

To download jdk, I suggest you go to 360 Software Manager to search and download, it is simple and convenient.

Tip: Installing jdk will automatically install java, so you don’t need to install java separately. If you have already installed java before, you can click Close in the upper right corner to exit the java installation when installing jdk to the step of installing java. . (Basically, you just need to click Next, and you only need to select the default installation directory.)

How to use java

2. Configure Java environment variables

Open Computer Properties, "Advanced System Settings" → "Environment Variables",

Create a new variable The name "JAVA_HOME" value is "jdk installation path"

How to use java

The new variable name "CLASSPATH" value is ".;%JAVA_HOME%\lib"

How to use java

Modify the variable name "path" and add "%JAVA_HOME%\bin;" at the front

How to use java

##3. Installed. Start writing programs.

Congratulations! Once the above steps are completed, we can start writing the program. Are you a little impatient? hey-hey.

Create a new text file on the desktop and paste the following content

public class HelloWorld{
public static void main(String []args)
{
System.out.println("hello world");
}
}
Copy after login


How to use java

## Exit and click Save

Change the extension to java and the file name to HelloWorld (H and W are capitalized)

Hold down the shift right button of the mouse and select "Open command window here" to open cmd

Enter javac (a space) HelloWorld.java and press Enter. At this time, a word HelloWorld.class will be generated on the desktop. Section code file, this is the compiled file

Then execute java (a space) HelloWorld

Congratulations! "hello world" appears!

How to use java

How to use java##

The above is the detailed content of How to use 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!