I read the article, so you have a new understanding of Java! (Installed JDK, configure the environment variables, application)

Hello everyone, I'm qi Star

Today I want an article, so that everyone from Java Quick Start white!

Perhaps you have not understood the high-level language, maybe you have the basis for other high-level language. It does not matter, read this article, Getting Started with Java is very simple!

The following article from the public [No.] Honker, Java reply within public sign to get the video to learn
Here Insert Picture Description
why we want to learn high-level language?

Haha, this problem can not be said to be the computer you're smart, let the computer help you do things ~

Computer programming is to tell the computer what to accomplish one thing needs to be done, how to do it. While the computer itself is versatile, powerful, perseverance, hard working, he stood by their jobs. This is a powerful place of the computer is that people with no way comparable.

But before it worse, is that people will pay it a program, so it can always do so.

So, to learn high-level language, it is to let the computer help you do things! And is the kind of hard working -

Why learn high-level language to learn Java?

At present, many new technologies could be seen Java. For example, Android applications, Web application JSP, Java large data mining procedures. Java everywhere, now the IT market for Java engineers are also in great demand. So, if you can be familiar with Java, it means you have a better employment prospects.

In this regard network programming, Java can be in veteran status. Which has a simple syntax, object-oriented, stable, secure, platform-independent, dynamic, multi-threading and so on.
Here Insert Picture Description
If you learn C or C ++, you come to learn Java, it will feel easier to get started, because they have almost the same control statements, loop statements, and so on.

Although they have the same part, but it is a different language on their nature, they have their own advantages.

Java has been able to quickly swept the world's one of the reasons, and that is platform-independent, platform-independent Why is that Java can provide a Java runtime environment on the computer's operating system, we called JRE (Java Runtime Environment). The environment consists of the Java Virtual Machine JVM (Java Virtual Machine), as well as some of the core library files. So, as long as the Java runtime environment installed on the operating system, then the Java code can run on them.

Next, we installed environment it!

JDK installation and configuration environment variable

JDK installation package I have on network drive, you can reply [JDK] to get in a public number.

After get the JDK installation package, we double-click to run, because the installation JDK without paying attention to what matters, so you can follow step by step installation steps on the line. Remember: Do not modify the installation path, the default on the C drive. C: \ Program Files \ Java

After successful installation, you will be able to find in the above path
Here Insert Picture Description
next will have to configure the environment variables.

If your computer is win10, then follow step by step the figure below

First, right-click on this computer icon and click Properties

Here Insert Picture Description
Click on Advanced System Settings
Here Insert Picture Description
click Environment Variables

New user variable as shown
Here Insert Picture Description
New system variables shown in the following FIG.

Note:. ";" In the column variable value, preceded under the English input method
Here Insert Picture Description
after adding and click OK

If your system is win7, then a user variable with the same system variable to find the path that one can directly add as win10 as the path after the character can be.

When we finished configuring environment variables, let's test to see whether the configuration.

win key + R, type cmd, and window open command

Enter then enter java -version

If the display shown in FIG character, the configuration was successful.
Here Insert Picture Description
Sample Java application

import javax.swing.JFrame;
import java.awt.*;

public class Cardioid extends JFrame {
    private static final int WIDTH = 500;
    private  static  final int HEIGHT = 500;
    private static int WINDOW_WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
    private static int WINDOW_HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;

    public Cardioid(){
        super("heart");
        this.setBackground(Color.BLACK);
        this.setLocation((WINDOW_WIDTH-WIDTH)/2,(WINDOW_HEIGHT-HEIGHT)/2);
        this.setSize(WIDTH,HEIGHT);
        this.setLayout(getLayout());
        this.setVisible(true);
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }
    public void paint(Graphics g) {
        double x, y, r;
        Image image = this.createImage(WIDTH, HEIGHT);
        Graphics pic = image.getGraphics();
        for (int i = -2; i < 90; i++) {
            for (int j = -2; j < 90; j++) {
                r = Math.PI / 45 + Math.PI / 45 * i * (1 - Math.sin(Math.PI / 45 * j)) * 18;
                x = r * Math.cos(Math.PI / 45 * j) * Math.sin(Math.PI / 45 * i) + WIDTH / 2;
                y = -r * Math.sin(Math.PI / 45 * j) + HEIGHT / 3;
                pic.setColor(Color.red);
                pic.fillOval((int) x, (int) y, 2, 2);
            }
            g.drawImage(image, 0, 0, this);
        }
    }
    public static void main(String[] args){
        new Cardioid();
    }
}

Operating results, see below
Here Insert Picture Description
for the above Java programs interest you? I will tell you in the solution Java knowledge, public reply here [No.] can get Java Java learning video.
I am concerned, you can get new skills every day!

Published 30 original articles · won praise 16 · views 3104

Guess you like

Origin blog.csdn.net/weixin_43729943/article/details/103847660