In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to install and use Java13", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's take you to learn "How to install and use Java13"!
Java 13 New Features
This release brings the following new features:
JEP 350, Dynamic CDS Archives: Extended application classes-data sharing to allow dynamic archiving of classes at the end of Java application execution. Archive classes will include all loaded application classes and library classes that do not exist 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: Replace the underlying implementation used by java. net.Socket and java. net.ServerSocket APIs with a simpler, more modern implementation that is easier to maintain and debug.
JEP 354, Switch Expressions (Preview): Switch expressions that can be used in production environments, a beta implementation coming with JDK 13. The switch expression extends the switch statement so that it can be written not only as a statement but also as an expression, and both can be written using the traditional switch syntax or using the simplified "case L ->" pattern matching syntax to act on different scopes and control execution flow. These changes will simplify day-to-day coding and set the stage for pattern matching in switch (JEP 305).
JEP 355, Text Blocks (Preview): Adding 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 way, and lets developers control formatting when needed.
Installing JDK 13
JDK 13 download address is.
For Windows environments, for example, install via jdk-13_windows-x64_bin.exe or jdk-13_windows-x64_bin.zip. The installation method of.exe file is relatively simple. Click "Next" according to the interface prompt.
Here's a demonstration. zip installation method.
1. Decompress. zip file to the specified location
Unzip the jdk-13_windows-x64_bin.zip file to the specified directory. For example, this example is placed at D:\Program Files\jdk-13.
2. set the environment variable
Create a system variable "JAVA_HOME" whose value points to the JDK installation directory.
In the user variable "Path", add "%JAVA_HOME%\bin".
Note: JDK13 no longer requires JRE installation, and CLASSPATH is not required when setting environment variables.
3. verify the installation
Execute "java -version" command to verify installation:
$ java -versionjava version "13" 2019-09-17Java(TM) SE Runtime Environment (build 13+33)Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)
If the above message is displayed, JDK installation is complete.
If the content displayed is still the old JDK version before installation, follow these steps to resolve it.
First, uninstall older versions of JDK
Next, enter the following commands on the command line to set JAVA_HOM and Path:
>SET JAVA_HOME=D:\Program Files\jdk-13>SET Path=%JAVA_HOME%\binEclipse IDE 2019-09
On September 19, 2019, two days after Java 13 was released, Eclipse IDE 2019-09 was released. Eclipse IDE 2019-09 claims support for Java 13. The following is an example of how to write Java 13 using Eclipse IDE 2019-09.
This example uses Eclipse version 4.14.
Writing Java 13 Examples 1: Examples of Switch Expressions
Here is how the original Switch expression would be 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 changed to read:
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 changed to read:
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 condition is required};System.out.println(date);
Note that when using yield, there must be a default condition.
Combat 2: Text Block
Since Java 13, text blocks have been supported.
Here is an example of how text blocks before Java 13 were handled:
String html = "\n" + " \n" + "
Hello, world
\n" + " \n" + "\n";System.out.println(html);
In the example above, because the text block needs to wrap, a lot of the stitching and escaping in this article occurs.
Here are some examples of text blocks in Java 13:
String html2 = """
Hello, world
"""; System.out.println(html2);
In the above example, the processing of text blocks becomes concise and natural.
The above two examples output the same content in the console, and the effect is as follows:
Hello, world
At this point, I believe that everyone has a deeper understanding of "how to install and use Java13," so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.