[Java] Modules

Module defined what can be used inside the module package and what outside world can use inside our module.

module-info.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

module HelloWorld {
    
    requires java.desktop;
    exports helloworld;
    
}

 

Because it requires java.desktop, therefore we can use BufferedImage class:

Greeting.java

package helloworld;

import java.awt.image.BufferedImage;


/**
 *
 * @author bethan
 */

public class Greeting {
    
    BufferedImage image;

    public static void main(String[] args) {
        System.out.println("Hello world");                
    }
    
}

 

posted @ 2021-01-04 02:44  Zhentiw  阅读(102)  评论(0)    收藏  举报