The first day, java_day01

Source: Internet
Author: User

Definition of software:
A collection of computer data and instructions organized in a specific order

How the software interacts:
1. GUI of graphical interface;
2. command line mode CLI;

Java language Features: cross-platform;
Java files are cross-platform under the JVM, but the JVM is not a cross-platform

Core class libraries required for Jre:jvm+java programs
Development tools for Jdk:jre+java

The most important folder name for the JDK installation folder: Bin (binary: binary) contains the development tools that the JDK has given us
The reason for the Javac.exe under the bin file is that it is not a graphical interface program, but a command-line interface program that requires DOS to be opened under Windows.

DOS command line, commands common in the course
Dir: Lists the files and folders in the current directory
MD: Create directory (make directory)
RD: Deleting a directory
CD: Enter the specified directory CD jdk* (regular expression indicates that files beginning with the JDK are selected to open)
CD: Back to top level directory
Cd\: Go back to the root directory
Del: Delete File del *;d el * *;d el *.txt (* is a wildcard);
Exit: Exit the DOS command line;
Help: assistance commands; If you want to know the detailed usage of an instruction, such as a CD, you can write:

Two steps to execute a Java program: (1) Java Source file (programmer-written *.java file)----Generate *.class files (bytecode files) using JAVAC compilation---Use Java commands to interpret the machine code that executes---build a specific platform-run successfully

Environment variables: Environment variables (environment variables) are generally used in operating systems to specify the operating system environment of some parameters, such as: temporary folder location and system folder location, etc.

Java-vresion: Query native Java JRE version number, note: A machine may have multiple Java versions installed
Therefore, you can use Javac-version (version number) to compile the specified version

Cmd.exe state Input Help,set instruction can view environment variable set path

Path environment variable temporary settings: The path set under CMD will only be set in the current form, the value of path will not change after closing cmd, so only the current cmd is valid, so it can be used as a temporary configuration for the environment variable.
The temporary environment variable, which gets the current environment variable dynamically and adds it behind, instead of rewriting: set path = e:\123\bin;%path% (which effectively gets the value of the previous path): The purpose of this writing is to dynamically load different versions of the JDK or MySQL program, It's best if you put the dynamic load in front of the%path%, which allows the system to ignore the software name with the same name, only the previous tag.

Note: The class name must be the same as the file name, or Javac compilation error

string[in Main (string[] args) What does args mean?
This is the formal parameter of the main method in the main class, and is a string object array that holds the parameters that are taken with the Java application, as in the following parameters in the DOS command.
If you are writing a Java program to copy a location file to another location, the compiled program is named Copyfile.class, the C:\a\1.txt is copied to D:\b\, and the file name is changed to B.txt, the command line interprets the execution:
Java copyfile C:\a\1.txt D:\b\b.txt, note that there are spaces between the four parts, two parameter strings exist in the array args, and you can access them in the program.

The Main method is the entry


public class helloworld{
public static void Main (string[] args) {
System.out.println ("Hello world!");
for (String S:args) {
System.out.println (s);
}
}}

CMD execution: Javac Helloworld.java
Java HelloWorld 1.7988p 29ioy (Java executes the name of the class)
CMD output: Hello world!
1.7988p
29ioy

One of the important points of writing a program is that reading is the first person to be able to understand, to make maintenance and to modify, and functionality is the second place.

The first day, java_day01

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.