Learn Java 8-start from HelloWorld

Source: Internet
Author: User

Install Java-Developed infrastructure download, install JDK

1. Visit http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2, download the corresponding operating system JDK

  

3. Installing the JDK

Install directly on the Windows system.

Under the Linux system, unpack the taar.gz package. Other operating systems, not tested.

ArchLinux, add two lines at the end of the/etc/pacman.conf file:

    [ARCHLINUXCN]    Siglevel = Optional Trustall    Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch After joining the above repo, execute the following script: sudo Pacman-syvu sudo pacman-s jdk
Configuring Environment variables

1. Under Windows, configure the Java_home and set path. Because JAVA8 only supports Vista or more than Windows, it only describes how the system is set up in Vista or later.

Right-click on the computer, select Properties, and in the top left corner of the popup page, select Advanced System Properties. As shown in the following:
  

In the above click on the environment variable, add Java_home, as shown (in, the variable value should be changed to the Java JDK path you installed):

    

Set path, in the system variable, find the line of path, double-click into the Edit System variable window, add%java_home%\bin in the value of the variable, the semicolon is indispensable. As follows:
    

Open a command prompt, press shift +r, enter java-version, which displays the relevant version information. As shown in the following:

    

2, set the environment variables under Linux. If you are using ArchLinux, you do not need to set the environment variable if you use the method of adding ARCHLINUXCN repo to install it.

The tar.gz package of the JDK downloaded on the Oracle website is extracted and then switched to the home directory (home directory, also called home directory), by editing the. bashrc file, setting java_home and path, in a way similar to Windows. The specific commands are as follows:

    

# # # # # # # # # # # # # # # Add Java_home and path settings to the home directory Cdvi. bashrc## can also use a text editor, such as using Kate under KDE, Gedit under GNOME, and so on. # # Assuming that the extracted JDK path is in/home/twinkle/jdk1.8export java_home=/home/twinkle/jdk1.8export path= $JAVA _home/bin: $PATH

# # After editing the. BASHRC, perform the following command test.
source. BASHRC
Java-version

# # above two commands, the first command let the set. BASHRC take effect immediately, and then test to get the Java version is correct.
Write the first program

After the installation and environment variables are set up for Java, we'll start our Java journey. Of course, it also started from HelloWorld. Create a new text, write the following code, and save it as Hello.java.

public class Hello {public    static void Main (string[] args) {        System.out.println ("Hello World. ");    }  }
Compile, run

After editing the Hello.java above, open the command-line window (cmd of Windows, the command prompt. Linux shell), followed collectively by the Command Line window. In the command-line window, switch the current path to the file path where you wrote Hello.java. Perform
As the following command, the effect:

  

Summary

In the basics of Java, first of all, the configuration of Java environment variables, so that the machine can run Java programs, and then from the base, from the text editor to write HelloWorld, slowly step by step in depth, of course, I have been doing a few years of procedural apes, follow-up examples, I wrote it in the idea Community edition, mainly because Google no longer supports eclipse writing Android. I've been using eclipse for the past few years and I want to familiarize myself with the use of idea by re-learning Java. Idea has always been known as the code artifact, but I never felt it. Perhaps, do not pay much attention to the operation of various shortcuts. Finally thank you for reading this article.

Learn Java 8-start from HelloWorld

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.