Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the reason why Java is still the mainstream language in the future

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

The main content of this article is to explain "why Java is still the mainstream language of the future". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "why Java is still the mainstream language of the future".

A brief introduction to 1.0 Java

For example: Spring-Rest (Spring MVC) core code:

For example: Spark Spark Streaming

Java basic knowledge diagram

Overview of Java basic courses

Java basic course system

1.1 introduction to software development

Software development

Software is a collection of computer data and instructions organized in a specific order. It can be divided into system software and application software.

Human-computer interaction mode

The graphical interface (Graphical User Interface GUI) is simple and intuitive, easy for users to accept and easy to use.

Command line mode (Command Line Interface CLI) requires a console to enter specific instructions for the computer to complete some operations. It is troublesome and needs to record some commands.

Commonly used DOS commands

Dir lists the files and folders in the current directory

Md create directory

Rd delete directory

Cd enters the specified directory

Cd.. : return to the directory one level above

Cd goes back to the root directory

Del deletes a file

Exit: exit the dos command line

Add: echo javase > 1.doc

Common shortcut keys

←←→→: moving cursor

↑↑↓↓: access history operation command

Delete and Backspace: deleting characters

1.2 introduction to computer programming language

1. What is computer language?

* * language: * * is a way of communication between people. For example, Chinese and Chinese communicate in Putonghua. If the Chinese want to communicate with the British, they have to learn English.

* * computer language: * * the way people communicate with computers.

If people want to communicate with computers, they must learn computer language.

There are many kinds of computer languages. Such as: C, C++ Che Zhen Java, PHP Kotlin Python Scala and so on.

* * first generation language: machine language. * * instructions exist in the form of binary code.

* * second generation language: Assembly language. * * use mnemonics to represent a machine instruction.

The third generation language: high-level language

C, Pascal, Fortran process-oriented languages

C++ process-oriented and object-oriented

Java cross-platform pure object-oriented language

.net cross-language platform

Python, Scala...

two。 Why Java?

Reason 1: such as the Android system structure of Google

Java development is more efficient (object-oriented)

The development cycle of python is short, but the running time is long, so both have their advantages.

A large community with a large number of people

Reason 2: from the market demand of java language

1.3 Overview of Java language

1. Basic concept

It is a high-level programming language introduced by SUN (S tanford U niversity N etwork, Stanford University Network) in 1995.

Is an Internet-oriented programming language. Java was attractive at first because Java programs can be run in Web browsers. These Java programs are called Java Mini Program (applet). Applet uses a modern graphical user interface to interact with Web users. Applet is embedded in the HTML code.

With the continuous maturity of Java technology in web, it has become the preferred development language for Web applications.

Background development: Java, PHP, Python, Go, Node.js

2.Java technology system platform

Application of 3.Java in various fields

From the application field of Java, the application direction of Java language is mainly shown in the following aspects:

Enterprise applications: mainly refers to complex large enterprise software systems, various types of websites. The security mechanism of Java and its cross-platform advantages make it widely used in the field of distributed system development. Application fields include finance, telecommunications, transportation, e-commerce and so on.

Android platform application Android application is written in Java language. The level of Android development largely depends on whether the core competence of the Java language is solid or not.

Big data platform development: all kinds of frameworks include Hadoop spark storm flink, etc. In terms of this kind of technical ecosystem, there are also various middleware such as flume kafka sqoop, etc. Most of these frameworks and tools are written in Java, but provide various languages such as Java scala Python R API for programming.

Mobile applications: mainly in the field of consumption and embedded, refers to a variety of small devices applications, including mobile phones, PDA, set-top boxes, automotive communication equipment and so on.

4. Main characteristics

The Java language is easy to learn. The syntax of Java language is very similar to C language and C++ language, which makes it easy for most programmers to learn and use Java.

The Java language is mandatory object-oriented. The Java language provides primitives such as classes, interfaces and inheritance. For simplicity, it only supports single inheritance between classes, but supports multiple inheritance between interfaces, and supports the implementation mechanism between classes and interfaces (keyword is implements).

Java language is distributed. Java language supports the development of Internet applications. There is a network application programming interface (java net) in the basic Java application programming interface, which provides a class library for network application programming, including URL, URLConnection, Socket, ServerSocket and so on. Java's RMI (remote method Activation) mechanism is also an important means of developing distributed applications.

The Java language is robust. Java's strong typing mechanism, exception handling and automatic garbage collection are important guarantees for the robustness of Java programs. Discarding pointers is a wise choice for Java.

The Java language is secure. Java is usually used in the network environment, for this reason, Java provides a secure machine system to prevent malicious code attacks. Such as: security mechanism (class ClassLoader), such as assigning different namespaces to avoid replacing local classes of the same name, bytecode checking.

The Java language is architecture neutral. Java programs (files with the suffix java) are compiled into an architecture-neutral bytecode format (files with the suffix class) on the Java platform, and can then be run on any system that implements the Java platform.

The Java language is interpretive. As mentioned earlier, Java programs are compiled into bytecode format on the Java platform and can then be run in the interpreter of any system that implements the Java platform.

Java is slightly higher in performance. Java performs better than those interpreted high-level scripting languages.

The Java language is natively multithreaded. In the Java language, a thread is a special object that must be created by the Thread class or its descendant class.

1.4 operating mechanism and process

The characteristics of 1.Java language

Special point 1: object-oriented

Two basic concepts: class and object

Three characteristics: encapsulation, inheritance and polymorphism

Special point 2: robustness

It absorbs the advantages of CAccord +, but removes the parts that affect the robustness of the program (such as pointers, memory application and release, etc.), and provides a relatively secure memory management and access mechanism.

Special point 3: cross-platform

Cross-platform: applications written in Java can run on different system platforms. Write once, Run Anywhere

Principle: just install a Java virtual machine (JVM Java Virtual Machine) on the operating system that needs to run java applications. JVM is responsible for the operation of the Java program in the system.

Because of JVM, the same Java program can be executed on three different operating systems. In this way, the cross-platform nature of Java programs is realized.

Two core mechanisms of 2.Java

Java Virtual Machine (Java Virtal Machine)

Garbage collection mechanism (Garbage Collection)

Core mechanism garbage collection

Memory space that is no longer used should be recycled.

The programmer is responsible for reclaiming unwanted memory in languages such as CAccord Category +.

The Java language eliminates the responsibility of programmers to reclaim useless memory space: it provides a system-level thread to track the allocation of storage spaces. And when the JVM is idle, check and release the storage space that can be freed.

Garbage collection occurs automatically during the running of Java programs, and programmers cannot accurately control and intervene.

Will Java programs still have memory leaks and memory overflows? Yes!

1.5 Java environment construction

Download JDK

Install JDK

Configure environment variables

The path to search for when the path:windows system executes the command.

Verify success: javac java

Choose the appropriate text editor or IDE developer

1. Make clear what is JDK, JRE

To put it simply, java programs that are completed using JDK's development tools are handed over to JRE to run.

2.JDK, JRE, JVM relationships (key points)

Install JDK

Installation, the next step can be.

Suggestion: the installation path should not have special symbols such as Chinese or spaces.

If the operating system is 64-bit, the software tries to choose to support 64-bit (unless the software itself is indistinguishable.

When prompted to install JRE, it is normally installed during JDK installation, but in order not to report errors in subsequent use of development tools such as Eclipse, it is recommended to install JRE according to the prompts.

3. Configure the environment variable path

Type javac on the dos command line and an error prompt appears

* * cause of error: * * if the currently executed program does not exist in the current directory, the windows system will look in the directory specified by an environment variable named path that already exists in the system. If it is still not found, the above error prompt appears. So go to the bin directory of the jdk installation path, execute javac, and you will see the javac parameter prompt. In order to execute successfully in all files, you need to configure link variables.

Extra: view JDK version

Every time the tool that executes java has to go to the bin directory, it is very troublesome. Is it possible to execute java tools in any directory?

According to the principle that the windows system is looking for executable programs, we can define the path where the java tool is located in the path environment variable, and let the system help us to find the program to run and execute.

Configuration method:

My computer properties advanced system settings environment variables

Edit the path environment variable and add the directory where the java tool is located at the beginning of the variable value, separated by ";" from other values.

Open the DOS command line and type javac in any directory. If the parameter information of javac appears, the configuration is successful.

4. Verification after configuring the path environment variable

5. Configuration problem summary resolution

Multiple JDK versions are allowed to be configured, but only one when used

If java or javac cannot be done at the same time, put JAVA_HOME first

If the user variable is not good, put it directly in the environment variable.

1.6 Development experience HelloWorld

Steps:

\ 1. Write the Java code into a file with a .java extension.

\ 2. Compile the java file through the javac command.

\ 3. Run the generated class file through the java command.

Step 1: write

Choose the simplest editor: notepad.

Type in the code class Test {} to save the file as Test.java, which is the file where the java code is stored, called the source file.

Step 2: compile

With the java source file, the compiler compiles it into a bytecode file that JVM can recognize.

In the source file directory, compile the Test.java file through the javac compilation tool.

If there is no error in the program, there is no prompt, but a Test.class document appears in the current directory, which is called a bytecode file, and is also an executable java program.

Step 3: run

With the executable java program Test.class bytecode file

Execute the bytecode file by running the tool java.exe.

A prompt appears: a method named main is missing.

Because the execution of a program requires a starting point or entry, add public static void main (String [] args) to the Test class

The modified Test.java source file needs to be recompiled, and a new class file is generated before execution.

It was found that the compilation did not fail, but it had no effect, because it did not tell JVM what to do for us, that is, there were no specific statements to execute.

To interact with JVM, simply add a System.out.println sentence to the main method ("Hello is recompiled and run because the program has changed."

1.7 Common problems and solutions

The source file name does not exist or is misspelled

Current path error

Suffix name hiding problem

Be careful when the class file name is misspelled, especially if the file name does not match the class name

The class file is not under the current path or under the path specified by classpath

The class declared as public should be the same as the file name, whether the compilation failed

Compilation failed, pay attention to the number of lines in the error, and then go to the specified location in the source code to correct the error

1.8 comment

1. The necessity of annotations

The text used to annotate the interpreter is a comment.

Comment types in Java:

Single-line comments, format: / / comment text

Multiline comments, format:: / * comment text * /

Document comments improve the readability of the code; an important way to debug programs.

Annotations are good programming habits that a programmer must have.

Sort out your ideas through comments, and then reflect them in code.

Note:

For single-line and multiline comments, the annotated text will not be interpreted and executed by the JVM java virtual machine.

Nesting of multiline comments is not allowed in multiline comments.

two。 Documentation comments (specific to Java)

Format:

@ author specifies the author of the java program

@ version specifies the version of the source file

The content of the comments can be parsed by the tool javadoc provided by JDK to generate a set of documentation of the program in the form of a web page file.

Mode of operation

Summarize the first program

The Java source file has the extension "java". The basic components of the source file are the class class, such as the Hello World class in this example.

The execution entry of the Java application is the main () method. It has a fixed writing format public static void main (String [] args)

The Java language is strictly case sensitive. But window makes no distinction.

The Java method consists of statements, each ending with ";".

Curly braces appear in pairs and are indispensable.

There can be at most one public class in a source file. There is no limit to the number of other classes, and if the source file contains a public class, the file name must be named after that class name.

Summarize the first java program

The process of writing, compiling and running 1.java programs

Writing: we save the written java code in the source file ending with ".java" I

Compile: use the javac.exe command to compile our java source file. Format: javac

Run: use java. The exe command interprets and runs our bytecode file. Format: java class name

two。 Multiple class can be declared in a single java source file.

However, at most one class can be declared as public.

It also requires that the class name of the class declared as public must be the same as the source file name.

3. The entry to the program is the main () method. The format is fixed.

4. Output statement:

System.out.print1n (): output data first, then wrap the line

System.out.print (): output only data

The 5.Java method consists of statements, each ending with ";".

6. The process of compilation: after compilation, one or more bytecode files are generated. The file name of the bytecode file is the same as that of the java source file

1.9 API documents

API (Application Programming Interface, Application programming Interface) is the basic programming interface provided by Java.

The Java language provides a large number of basic classes, so Oracle also provides API documentation for these basic classes to tell developers how to use these classes and the methods contained in these classes.

1. Download API

two。 Learn how Java looks at API (detailed illustration) + view Java source code (IDEA)

1.10 good programming style

1. Correct comments and annotation style

Use documentation comments to annotate the entire class or method.

If there is a step in the comment method, use a single-line or multiple-line comment.

two。 Correct indentation and white space

Use a tab operation to achieve indentation

Operator habitually adds a space on each side. For example: 2 + 4 * 5.

3. The style of the block

Java API source code chooses end-of-line style

1.11Common Java development tools

Text editing tools:

Notepad

UltraEdit

EditPlus

TextPad

NotePad

1. The relationship among JDK, JDK and JRE, and what are the main structures included in JDK and JVMs?

JDK = JRE + Java development tools (javac.exe,java.exe,javadoc.exe)

JRD = JVM + Java Core Class Library

two。 Why configure the path**** environment variable? How to configure it?

I hope it can work properly under any path.

Create the JAVA_HOME variable, the upper directory of JAVA_HOME=bin

Path=%JAVA_HOME%/bin

3. What are the common command line operations? (at least 4)

Cd goes to the directory

Cd... Return to the parent directory

Cd/ returns the root directory

Dir display directory

Md create directory makedirectory

Rd delete directory rmdir

Del deletes a file

Exit exit

4. Create the following classes so that the runtime can output:

Create a java file: ChairMan.java

5. Instructions for compiling and running the above code

Compilation: javac ChairMan.java

Run: java ChairMan

At this point, I believe you have a deeper understanding of "why Java is still the mainstream language of the future". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report