Home Java javaTutorial How to install and use Java13

How to install and use Java13

Apr 24, 2023 pm 05:10 PM
java

Java 13 new features

This version brings the following new features:

  • JEP 350, Dynamic CDS Archives: Extends Application Classes - Data Sharing to allow dynamic archiving of classes at the end of Java application execution. The archived classes will include all loaded application and library classes that are not present in the default base layer CDS (class data-sharing) archive.

  • JEP 351, ZGC: Uncommit Unused Memory: Enhance ZGC to return unused heap memory to the operating system.

  • JEP 353, Reimplement the Legacy Socket API: Replaces the underlying implementation used by the java.net.Socket and java.net.ServerSocket APIs with a simpler, more modern implementation that is easy to maintain and debug.

  • JEP 354, Switch Expressions (Preview): Switch expressions that can be used in production environments, a beta version implementation will be brought in JDK 13. The switch expression extends the switch statement so that it can be used not only as a statement but also as an expression, and both writing methods can use the traditional switch syntax, or use the simplified "case L ->" Pattern matching syntax operates on different scopes and controls the flow of execution. These changes will simplify daily coding tasks and prepare you for pattern matching in switch (JEP 305).

  • JEP 355, Text Blocks (Preview): Add text blocks to the Java language. A text block is a multiline string literal that avoids the need for most escape sequences, automatically formats strings in a predictable manner, and gives the developer control over formatting when needed.

Install JDK 13

The download address of JDK 13 is .

Taking the Windows environment as an example, you can install it through jdk-13_windows-x64_bin.exe or jdk-13_windows-x64_bin.zip. The installation method of .exe file is relatively simple, just click "Next" according to the interface prompts.

The following demonstrates the .zip installation method.

1. Unzip the .zip file to the specified location

Extract the jdk-13_windows-x64_bin.zip file to the specified directory. For example, this example is placed in the D:\Program Files\jdk-13 location.

2. Set environment variables

Create the system variable "JAVA_HOME", whose value points to the JDK installation directory.

How to install and use Java13

In the user variable "Path", add "%JAVA_HOME%\bin".

How to install and use Java13

Note: JDK13 no longer requires the installation of JRE, and there is no need to set CLASSPATH when setting environment variables.

3. Verify installation

Execute the "java -version" command to verify the installation:

$ java -version
java version "13" 2019-09-17
Java(TM) SE Runtime Environment (build 13+33)
Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)

If the above information is displayed, it means that the JDK has been installed.

If the displayed content is still the old JDK version before installation, you can follow the steps below to solve the problem.

First, uninstall the old version of JDK

How to install and use Java13

Secondly, enter the following instructions on the command line to set JAVA_HOM and Path:

>SET JAVA_HOME=D:\Program Files\jdk-13

>SET Path=%JAVA_HOME%\bin

Eclipse IDE 2019-09

Eclipse IDE 2019-09 was released on September 19, 2019, two days after Java 13 was released. Eclipse IDE 2019-09 claims to support Java 13. Next, we will demonstrate how to use Eclipse IDE 2019-09 to write Java 13 examples.

This example uses Eclipse version 4.14.

Writing Java 13 examples

Practice 1: Example of Switch expression

The following is how the original Switch expression is written:

switch (day) {
    case MONDAY:
    case FRIDAY:
    case SUNDAY:
        System.out.println(6);
        break;
    case TUESDAY:
        System.out.println(7);
        break;
    case THURSDAY:
    case SATURDAY:
        System.out.println(8);
        break;
    case WEDNESDAY:
        System.out.println(9);
        break;
}

In Java 12, the Switch expression can be written as follows:

switch (day) {
    case MONDAY, FRIDAY, SUNDAY -> System.out.println(6);
    case TUESDAY                -> System.out.println(7);
    case THURSDAY, SATURDAY     -> System.out.println(8);
    case WEDNESDAY              -> System.out.println(9);
}

It also supports returning values ​​in expressions:

int numLetters = switch (day) {
    case MONDAY, FRIDAY, SUNDAY -> 6;
    case TUESDAY                -> 7;
    case THURSDAY, SATURDAY     -> 8;
    case WEDNESDAY              -> 9;
};

In Java 13, the Switch expression can be written as follows:

int date = switch (day) {
    case MONDAY, FRIDAY, SUNDAY : yield 6;
    case TUESDAY                : yield 7;
    case THURSDAY, SATURDAY     : yield 8;
    case WEDNESDAY              : yield 9;
    default                     : yield 1; // default条件是必须的
};

System.out.println(date);

It should be noted that when using yield, there must be a default condition.

Practical Combat 2: Text Block

Starting with Java 13, Text Blocks are supported.

Here is an example of how text blocks were handled before Java 13:

String html = "\n" +
                  "    \n" +
                  "        <p>Hello, world</p>\n" +
                  "    \n" +
                  "\n";

System.out.println(html);

In the above example, because the text block needs to be wrapped, a lot of splicing and escaping of this article occurs.

Here is an example of a text block in Java 13:

String html2 = """
                  
                      
                          <p>Hello, world</p>
                      
                  
                  """;
        
System.out.println(html2);

In the above example, processing text blocks becomes concise and natural.

The above two examples have the same output content on the console, and the effect is as follows:

    
        <p>Hello, world</p>
    

The above is the detailed content of How to install and use Java13. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Laravel lazy loading vs eager loading Laravel lazy loading vs eager loading Jul 28, 2025 am 04:23 AM

Lazy loading only queries when accessing associations can easily lead to N 1 problems, which is suitable for scenarios where the associated data is not determined whether it is needed; 2. Emergency loading uses with() to load associated data in advance to avoid N 1 queries, which is suitable for batch processing scenarios; 3. Emergency loading should be used to optimize performance, and N 1 problems can be detected through tools such as LaravelDebugbar, and the $with attribute of the model is carefully used to avoid unnecessary performance overhead.

python memory management example python memory management example Jul 28, 2025 am 01:10 AM

Python's memory management is based on reference counting and garbage collection mechanisms. 1. The reference counting mechanism ensures that objects are released immediately when the reference number is 0. The return value of sys.getrefcount() is 1 more than the actual reference because it increases its reference itself; 2. Circular references cannot be cleaned through reference counting, and it depends on the generational recycling of the gc module. Calling gc.collect() can recycle unreachable objects; 3. In actual development, long-term holding of large object references should be avoided. We can use weakref weak references, timely place None to release memory, and use tracemalloc to monitor memory allocation; 4. Summary: Python combines reference counting and garbage collection to manage memory, developers can use tools and optimize reference pipes.

Integrating PHP with Machine Learning Models Integrating PHP with Machine Learning Models Jul 28, 2025 am 04:37 AM

UseaRESTAPItobridgePHPandMLmodelsbyrunningthemodelinPythonviaFlaskorFastAPIandcallingitfromPHPusingcURLorGuzzle.2.RunPythonscriptsdirectlyfromPHPusingexec()orshell_exec()forsimple,low-trafficusecases,thoughthisapproachhassecurityandperformancelimitat

Laravel raw SQL query example Laravel raw SQL query example Jul 29, 2025 am 02:59 AM

Laravel supports the use of native SQL queries, but parameter binding should be preferred to ensure safety; 1. Use DB::select() to execute SELECT queries with parameter binding to prevent SQL injection; 2. Use DB::update() to perform UPDATE operations and return the number of rows affected; 3. Use DB::insert() to insert data; 4. Use DB::delete() to delete data; 5. Use DB::statement() to execute SQL statements without result sets such as CREATE, ALTER, etc.; 6. It is recommended to use whereRaw, selectRaw and other methods in QueryBuilder to combine native expressions to improve security

Optimizing Memory Usage in Java Applications Optimizing Memory Usage in Java Applications Jul 28, 2025 am 02:40 AM

UseefficientdatastructureslikeArrayListoverLinkedListandprimitivecollectionstoreduceoverhead;2.Minimizeobjectcreationbyreusingobjects,usingStringBuilderforconcatenation,andcachingexpensiveobjects;3.Preventmemoryleaksbynullifyingreferences,usingstatic

python ternary operator example python ternary operator example Jul 28, 2025 am 02:57 AM

Python's ternary operator is used to concisely implement if-else judgment, and its syntax is "value_if_trueif conditionelsevalue_if_false"; 1. It can be used for simple assignment, such as returning the corresponding string based on positive and negative values; 2. It can avoid division errors, such as determining that the denominator is non-zero and then division; 3. It can select content according to conditions in string format; 4. It can assign labels to different elements in list derivation formula; it should be noted that this operator is only suitable for binary branches and should not be nested multiple layers. Complex logic should use the traditional if-elif-else structure to ensure readability.

Reactive Programming in Java with Project Reactor and Spring WebFlux Reactive Programming in Java with Project Reactor and Spring WebFlux Jul 29, 2025 am 12:04 AM

Responsive programming implements high concurrency, low latency non-blocking services in Java through ProjectReactor and SpringWebFlux. 1. ProjectReactor provides two core types: Mono and Flux, supports declarative processing of asynchronous data flows, and converts, filters and other operations through operator chains; 2. SpringWebFlux is built on Reactor, supports two programming models: annotation and functional. It runs on non-blocking servers such as Netty, and can efficiently handle a large number of concurrent connections; 3. Using WebFlux Reactor can improve the concurrency capability and resource utilization in I/O-intensive scenarios, and naturally supports SSE and WebSo.

css table-layout fixed example css table-layout fixed example Jul 29, 2025 am 04:28 AM

table-layout:fixed will force the table column width to be determined by the cell width of the first row to avoid the content affecting the layout. 1. Set table-layout:fixed and specify the table width; 2. Set the specific column width ratio for the first row th/td; 3. Use white-space:nowrap, overflow:hidden and text-overflow:ellipsis to control text overflow; 4. Applicable to background management, data reports and other scenarios that require stable layout and high-performance rendering, which can effectively prevent layout jitter and improve rendering efficiency.

See all articles