Home > Java > javaTutorial > What are automatic modules in Java 9?

What are automatic modules in Java 9?

WBOY
Release: 2023-09-16 08:25:02
forward
1229 people have browsed it

Java 9中的自动模块是什么?

Auto module is a jar we put on the module path. There are many pre-existing libraries that can be used in our application, many of which are not yet modularized. To facilitate migration, we can add the jar file of any library to the module path of the application and then use the package from that jar file. It can become an automatic module implicitly and can be specified in the require directive of the module declaration. The filename of a jar becomes its module name, which must be a valid Java identifier that can be used in the "requires" directive.

AutomaticModules:

  • Implicitly export all package types, so any module that can read automatic modules ( Including unnamed modules ) must access public types in automatic module packages.
  • Implicitly read (required) all other modules, including other automatic modules and unnamed modules, so automatic modules have access to all public types exposed by other modules of the system.
<strong>%JAVA_HOME%\java --module-path ./libs:./libs-legacy --module app/com.app.Main</strong>
Copy after login

Automatic module naming:

  • Remove the extension ".jar".
  • Version number has been deleted. For example: mylib-1.2.3 -> mylib
  • Non-alphanumeric characters are replaced with periods.
  • Duplicate points are replaced with single points, and points at the beginning and end of the chain will be deleted.

The above is the detailed content of What are automatic modules in Java 9?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template