|
|
||
Mandy Chung's BlogSupport for the module keywordPosted by mandychung on July 25, 2008 at 12:10 PM | Comments (0)Very soon, in a week or two, the Java compiler (javac), packaging tool (jam), and the Java module system implementation in the OpenJDK Modules project will support the new The engineering team have built a special workaround to enable ourselves to build the Java module system while waiting for the language support. With the javac and jam tool support (thanks to Jonathan Gibbons and Kumar Srinivasan), you can now experience developing, building and packaging of a JAM module as JSR 277 spec defines. The language support for JSR 277 consists of two parts: module membership and module accessibility. The module accessibility support requires both the javac and JVM support which will go in next (stay tuned!). This blog is to help you get started to build and play with JAM modules using the JDK built from the Modules project with the module membership support. Module Membership Declaration There are two different ways to use the 1) To declare module membership in the individual source file of a class (recommended):
public class HelloWorld { 2) To declare module membership in package-info.java:
The Compile a module Since the module keyword is a new feature, you will need to run javac with -source 7 option: Module Compilation Unit A file called This
The You can download this sample aplication containing the hello, com.foo.OrderProcessingService, and com.bar.PrintService modules and try it out. Package a JAM Module The JDK provides a new JAM module packaging tool called "jam". To build the hello module: The jam command is similar to the jar command. The jam tool analyzes the list of input files and the module-info.class and generates the JAM module metadata (META-INF/MANIFEST.MF entry in the jam file). This metadata will be used by the Java Module System at runtime to enforce the versioning constraint and resolve the import dependency. To build the other two JAM modules provided in the sample application, Launch a Module Application Once you build the JAM modules, you can run the module application as follows: The -jam option is similar to the -jar option but launching a JAM module. Another way to launch the application: The -repository option specifies the source location of the JAM modules and the -module option specifies the module name containing the main entry point. Exercises There are few things you can try out:
Let us know what you think. Feedback and Questions Please send your feedback and questions to modules-dev@openjdk.java.net. We are working to post a JDK binary built from the Modules project once the module membership change is integrated (stay tuned). Bookmark blog post: CommentsComments are listed in date ascending order (oldest first) | Post Comment | ||
|
|