Day 1: Industry overview, course system introduction, JAVA development environment, course system java

Source: Internet
Author: User

Day 1: Industry overview, course system introduction, JAVA development environment, course system java
1. JAVA Development Environment 1.1. Understand the Linux operating system 1.1.1. The Origin and Development of Linux

Linux originated in 1991 and became popular in 1995. You can see this person next to it. It is called Linux. It is an operating system that he wrote when he was in college, it refers to open source code, that is, how to do it step by step can be seen. It is a Unix-like operating system, and Unix is also an operating system, but it is charged, while Linux is free. Of course, this is also one of the reasons for its development.

Currently, Linux is a mainstream server operating system and is widely used in the Internet, cloud computing, and smart phone (Android) fields. Because Java is mainly used for server-side development, many Java application deployment environments are Linux.

1.1.2. Linux directory structure

The directory structure of the Windows operating system is based on the drive letter, drive C, drive D, and drive E. data is stored under each drive letter, while the Linux operating system has only one root directory at the top, all files are stored under this root directory.

If an external device (such as a USB flash drive) is inserted in a Windows operating system, an additional drive letter H is provided in the system, and operations on the H disk are performed on the external device. In Linux, there is a sub-directory named mnt under the root directory root. In this directory, a directory appears, which is assumed to be sdcard and is called a mount point, the operation on it is the operation on the external device.

After a user logs on to a Windows operating system, the user has the permission to add, delete, modify, and query all files. That is, the user can operate any directory. Assume that the Windows directory under drive C is deleted, this will cause system exceptions and cause poor security. The Linux operating system has strict permission requirements. After a user logs on, the user does not have the permission to add, delete, modify, and query all directories. The default current directory is soft01 in the home directory under the root directory, which is called the home directory, this directory has the highest permissions, and other directory files are generally read-only and cannot be deleted at will, thus ensuring security.

1.1.3. pwd, cd, and ls commands

Most Linux operating systems for servers do not provide graphical interfaces, but operate through command lines, which is different from Windows. Linux provides many commands. The commands that are often used to operate directories are as follows:

  1. Pwd: used to display the current working directory.
  2. Ls: used to view the content of the current working directory.
  3. Cd: used to change the current working directory.
1.1.4. Relative Path and absolute path

The path specifies the location of a file or directory in the file system. There are two Representation Methods: relative path and absolute path. In general, we can choose which path to locate more quickly.

Relative Path: the location of the file or directory relative to the current working directory. For example, the path "soft01/workspace" indicates the workspace in the soft01 directory under the current directory. There are two special relative paths: ". "indicates the current directory," .. "indicates the upper-level directory.

Absolute path: the location of the file or directory relative to the root directory. The absolute path starts from. For example, "/home/soft01" indicates soft01 in the home directory under the root directory.

Let's take another example of how to go to Carrefour? Take the current position as the base point, exit the classroom door, go down to the first floor of the elevator, turn right at the gate and go straight for about 300 meters. The right side is the opposite path. It is fixed to longze as the base point. longze takes the subway station, Dazhong temple station, and goes straight for about 1000 meters. It is on the left. This is the absolute path.

1.2. JAVA Development Environment 1.2.1. Java compilation and running process

What programmers write is. java is a suffix file, which cannot be correctly identified by the operating system. Therefore, you must first compile the file to generate the so-called bytecode file (. class), while bytecode files require JVM to provide support for the runtime environment.

JVM is a software installed in the operating system and built on the operating system. It provides the runtime environment for bytecode files, as shown in-1.


Figure-1

Java officially provides JVM software for different platforms, that is, the JVM for different platforms is different. However, these JVMs follow the same standard, that is, as long as they are standard. class files, they can run on different JVMs, and the running effect is the same. In this way, the so-called "one-time programming is used everywhere" is implemented ". Result 2:


Figure 2

Java programs follow the principles of first compilation and then execution. First, use the javac command (. java file) compiled into JAVA bytecode (. class file), and then start the JVM using the java command, which is loaded by the JVM. class file and run. class file. Result 3:


Figure-3

1.2.2. JDK, JRE, JVM relationship

JDK (Java Development Kit) is a Java Development Kit that contains Development tools and JRE required for compiling and running Java programs. Development tools such as javac commands for compiling java programs, java commands for starting JVM to run java programs, javadoc commands for generating documents, and jar commands for packaging.

JRE (Java Runtime Environment) is a Java Runtime Environment that provides the software Environment necessary to run Java applications, including Java Virtual Machine (JVM) and a wide range of system class libraries. The system library is a functional class encapsulated in java in advance, which can be used directly, greatly improving development efficiency.

JVM (Java Virtual Machines) is a Java Virtual machine that provides Runtime Environment Support for bytecode files (. class.

JDK, JRE, and JVM-4 are shown in the following figure:


Figure 4

As shown in the figure below, JDK contains development tools such as compilation and running, and JRE contains the Java System Library and JVM, the minimum environment required for running a java program is JRE, and the minimum environment required for developing a Java program is JDK, because JDK also contains many commands used.

1.2.3. Install JDK

You can download and install JDK from the official address: http://www.oracle.com/technetwork/java/javase/downloads/index.html. The ing between the operating system (OS) version and the JDK version is shown in-5:


Figure 5

1.2.4. Configure Environment Variables

JDK provides many commands, such as compiling (javac) and running (java). If you want to use these commands, you need the operating system to find the path of these command files, you can configure the PATH environment variable.

The PATH environment variable is a series of directories. When executing a command, the operating system searches for the command in each directory of the PATH environment variable in sequence and runs the command if it is found. If it is not found, an error is prompted.

In Linux, the path of the configuration file is/etc/profile, and the profile file is the initialization script of the system. The script program will be automatically executed when the system starts up, you can use the cat command to view the content of the configuration file. The command is as follows:

cat /etc/profile

  

As you can see, there are already many configurations in it. They are set in advance and do not need to be modified. The Linux operating system is configured in the following simple way:

export JAVA_HOME=/opt/jdkexport CLASSPATH=.export PATH=/opt/jdk/bin:$PATH

 

1.3. Eclipse IDE1.3.1. introduction to Eclipse

In the "Java HelloWorld" program of the console, we used the simplest editing tool to compile the source code. However, in real enterprise projects, this original development method will bring about a lot of tedious, repetitive, and error-prone operations, greatly reducing the work efficiency, and is not conducive to overall project management. In real scenarios, developers always use some powerful "integrated development environment" to write, debug, test, submit, and refactor code, such as Eclipse.

Eclipse is currently the mainstream IDE Development Environment. The so-called Integrated Development Environment (IDE, Integrated Development Environment) is an application software designed for programmers. These software often has a powerful graphic interface. With the help of IDE, programmers can complete compilation, debugging, submission, and refactoring more efficiently. As a qualified programmer, we should have a high degree of proficiency in mainstream IDE tools, but we should also avoid the issue of "over-reliance on IDE.

For Java programmers, there are many IDE environments to choose from, but the most popular is a number of well-known Eclipse. Eclipse is an open-source project that IBM has spent tens of millions of dollars to build, and now it almost dominates the IDE market. Apart from open source, the biggest reason for Eclipse's success is that it is based on the "plug-in" feature. Eclipse itself is a platform framework that provides standard services. Many third-party vendors can use development plug-ins to expand Eclipse functions. Eclipse is highly flexible compared with other functions that are relatively fixed.

You can download free Eclipse from the official Eclipse website (http://www.eclipse.org/downloads. On the Eclipse download page, choose to download "Eclipse Classic". This version can be understood as there is no special installation plug-in "Standard Edition" Eclipse. For other versions, specific plug-ins are preset according to different needs.

After Eclipse is downloaded, you do not need to install it. You only need to decompress the downloaded package in a folder. Because Eclipse is also written in Java language, it requires a JRE environment to run, so JDK (or JRE) must be installed first ).

The following describes how to use Eclipse:

1) Step 1: enable the development tool Eclipse

After eclipse is started, the following dialog box is displayed, as shown in-27.


Figure-27

The pop-up dialog box "Workspace Launcher" is used to select "Workspace ). The so-called "workspace" refers to the path that Eclipse uses to store project files. Eclipse organizes materials through projects. The source files compiled by programmers, compilation and generation class files are stored in the project folder in a specific directory structure.

2) Step 2: Create a Java Project

Select the menu operation "File (NEW (Java Project") "to create a Project suitable for compiling Java basic applications. In the displayed dialog box, enter the Project Name and click "Finish. -28:


Figure-28

After the project is created, a folder with the same name as the project name is generated in the workspace directory (specified during Eclipse startup. Open this folder and you will see the directory structure shown in-29:


Figure-29

The "src" folder is used to store the Java source files compiled by the user, and the "bin" folder is used to store the class files automatically compiled by Eclipse. Eclipse supports automatic compilation. When you compile a Java source file, Eclipse automatically calls the system's JRE to compile the file and stores the compiled class file in the bin directory. In addition, the ". classpath" and ". project" files and the content in the ". settings" folder are used by Eclipse to maintain project information, which can be ignored.

3) Step 3: Create a class named HelloWorld

After the project is created, you can use "File (New (Class") "to create a Java source File. In the displayed dialog box, enter the Name and Package of the Java class to be created, as shown in-30. (The meaning of the package will be detailed in subsequent courses .)


Figure-30

After entering the class name ("HelloWorld" in this example) and package name ("day01" in this example), click "Finish. Eclipse creates a source file named HelloWorld. java.

4) Step 4: Define a class

Compile the HelloWorld program in Eclipse, as shown in-31.


Figure-31

After the program is compiled and you confirm that there is no compilation error, you can Run the program using the menu operation "Run As (Java Application. The running result is displayed in the Console view below the code. It should be pointed out that this operation is essentially similar to running a Java program using the command line method. It can be understood that Eclipse calls the java command of JDK, you can use a more user-friendly graphical interface to run Java programs.


Java Development Environment introduction, it is best to introduce Structs

1. Install jdk. You can download the latest version from the oracle website.
2. If you want to use structs, You have to install an application server. We recommend that you use tomcat, which is easy to use and produced by the same company as structs.
3. I don't have to worry about structs. You have a detailed description on its official website www.apache.org. There are also many examples. If you don't like English, you can also search structs in Baidu encyclopedia and get a satisfactory answer.

Compile a simple program to illustrate the steps for using the Java Development Environment

I. use Notepad:
1: Configure environment variables on your computer. After writing the code in your notebook, change the suffix .txt to. java.
2: Open DOS, find the current file, and enter: (compile) javac abc. java
(Run) java abc
2. Use MyEclipse.

Related Article

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.