Home  >  Article  >  Java  >  Getting started with Java 9

Getting started with Java 9

巴扎黑
巴扎黑Original
2017-06-23 16:30:271942browse

Text by / Lin Bentuo

Java 9

##In the first part, the main content is explained as follows:

  • JDK 9 includes What content

  • System requirements for running the code

  • How to install NetBeans

1 JDK Introduction

JDK 9 is the ninth major version of the Java Development Kit, scheduled for release in late July 2017. It brings many exciting new features. This set of tutorials mainly introduces useful functions for Java developers in daily programming. You can find a complete list of all features on .

One of the most important and exciting features of JDK 9 is the module system, developed under a project with the code name Jigsaw. JDK designers have been working to bring a module system to the Java platform for more than 10 years. It was planned to be part of several previous JDK versions and was later removed. The Jigsaw project has also delayed the release of the JDK 9 version many times. However, Jigsaw is taking active action recently and releasing a new JDK version.

Tips

Jigsaw is a sub-project under the OpenJDK project. It aims to design and implement a standard module system for the Java SE platform and apply it to the platform and JDK.

What difficulties did the Jigsaw project encounter that took so many years to complete? The main goal of Jigsaw is to provide Java developers with a way to develop applications using software components called modules. A module can export its API for public use and encapsulate its internals. Modules can also declare dependencies on other modules, and these dependencies can be verified at startup to avoid missing type errors at runtime. The JDK itself is divided into a series of modules that interact with each other. This provides a scalable runtime. If your application uses a subset of the JDK, you can create a runtime image that contains the JDK modules used in your application and application modules. All these features of the module system look normal. The main issue that has always troubled JDK designers is backward compatibility and migration of the module system. Java has been around for over 20 years. Any significant features, including the module system, must be easily applicable. Based on feedback from the Java community, it went through several iterations of redesign and improvement, and finally got to where it is now.

Another important addition to JDK 9 is JShell, Java’s interactive programming environment. JShell is a command line tool and API that allows executing a piece of code and getting instant feedback. Before JShell, you had to write a complete program, compile it and run it to get the results. JShell is a tool you use in your daily development. JShell is essential for beginners to help them learn the Java language quickly without knowing the details of program structure such as modules and packages.

In addition, JDK 9 also adds some other new features to make your development easier. For example, Reactive Streams API, collection factory methods, planned HTTP/2 Client API, Stack-Walking API, Platform Logging API and unified JVM logging.

2 System requirements for running the code

First, you need to download

JDK 9 (Java Development Kit 9). You need to download it from this website JDK9. If you can't access it, you can use Download.

First you need to agree to the license agreement, and then you can download it. Java 9 can run on many platforms:

  • Windows 32-bit

  • Windows 64-bit

  • macOS 64-bit (formerly known as Mac OS X * or simply OS X)

  • Linux 32-bit

  • Linux 64 -bit

  • Linux on ARM 32-bit

  • ##Linux on ARM 64-bit
  • The next step is to configure
environment variables

. The same as the previous JDK configuration method. Here, I take macOS 10.12 version as an example, the configuration on Macbook. Here you will need some basic operations of vi, you can go online to find how to use it. After downloading the JDK, run it directly. Then the installation directory is: /library/Java/JavaVirtualMachines/jdk-9.jdk/
Under Terminal, enter the current directory of your user (it is your user’s default directory when you open it, I really don’t know Type cd

on the command line to switch to the default directory). Execute the

ls -a
command on the command line to list files or directories including hidden files in the current directory.

ls -a4. Find the .bash_profile file. This file will affect your current user's configuration information, and execute the

vi .bash_profile

command to edit this file.
vi .bash_profile5. After entering the edit page, configure the Java Home and Path environment variables:

Configure Java environment variables

6. After configuring, use the esc key to exit the editing state, enter ":wq", save and exit. And execute . .bash_profile to make the configuration file take effect immediately. Execute javac -version on the command line. If the following information is output, it means the JDK configuration is correct.

javac 9-ea

At this point, the JDK configuration is complete.

3 How to install NetBeans

If you want to compile and run Java programs, you need to install an integrated development environment (IDE) on your computer, such as NetBeans or Eclipse. No IDE currently fully supports the module system in JDK 9. However, NetBeans supports the creation of one module per NetBeans project. That is, if you want to create three Java modules in NetBeans, you need to create three NetBeans Java projects. A Java module can reference other Java modules using project dependencies in NetBeans. Currently, NetBeans does not support multi-module Java projects. The latest information about module system support in NetBeans can be found on the wiki page: .

You can download the latest NetBeans version that supports JDK 9 from the following link:. There are many NetBeans versions for us to download. For convenience, we download the "All" version directly.

下载 NetBeans

At this point, the configuration of JDK 9 has been completed and NetBeans has been downloaded. The detailed configuration of NetBeans will be introduced in subsequent chapters.

The above is the detailed content of Getting started with Java 9. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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