Code Monkey home page Code Monkey logo

java_9_sneak_peek's Introduction

Java 9: module system

  • build custom JDK image:
cd D:\software\Java\jdk9_181
bin\jlink.exe --module-path jmods --add-modules java.logging --output D:/software/Java/jdk9_logging_only
  • encapsulate app server and applications:

create module-info.java for server and applications (in default packages):

module banking.server {
	requires java.logging;
	exports bg.jug.banking.server.applications;
	exports bg.jug.banking.server.protocol;
	exports bg.jug.banking.server.services;
	exports bg.jug.banking.server.protocol.permissions;
	uses bg.jug.banking.server.applications.BankingApplication;
	uses bg.jug.banking.server.protocol.BankingProtocol;
}
module protocol.alpha {
	requires java.logging;
	requires banking.server;
	provides bg.jug.banking.server.protocol.BankingProtocol with bg.jug.banking.protocol.alpha.AlphaProtocol;
}
module protocol.fix {
	requires java.logging;
	requires banking.server;
	provides bg.jug.banking.server.protocol.BankingProtocol with bg.jug.banking.protocol.fix.FixProtocol;
}
module application.demo {
	requires java.logging;
	requires banking.server;
	provides bg.jug.banking.server.applications.BankingApplication with bg.jug.banking.app.demo.DemoApplication;
}

build server module:

D:\stuff\seminars\BG_JUG\Java_9_sneak_peak\workspace
set PATH=D:\software\Java\jdk9_181\bin;%PATH%
mkdir modules\banking.server modules\protocol.fix modules\protocol.alpha modules\application.demo

dir /s /B banking-server\src\main\java\bg\jug\*.java > sources.txt
javac -d modules\banking.server banking-server\src\main\java\module-info.java @sources.txt

dir /s /B fix-protocol\src\main\java\bg\jug\*.java > sources.txt
javac --module-path modules -d modules\fix.protocol fix-protocol\src\main\java\module-info.java @sources.txt

dir /s /B alpha-protocol\src\main\java\bg\jug\*.java > sources.txt
javac --module-path modules -d modules\alpha.protocol alpha-protocol\src\main\java\module-info.java @sources.txt

dir /s /B demo-application\src\main\java\bg\jug\*.java > sources.txt
javac --module-path modules -d modules\demo.application demo-application\src\main\java\module-info.java @sources.txt

java --module-path modules -m banking.server/bg.jug.banking.server.Server
  • verify usage of internal APIs
cd banking-server
jdeps.exe -jdkinternals
jdeps.exe --compile-time .

Java 9: the good parts

  • jshell

bin\jshell

2 + 3
public int sum(int a, int b) { return a + b; }
import java.util.logging
import java.util.logging.*
Logger x = null;
class z {}
/help
/imports
/vars
/methods
/env
/types
/list
/list -all
/save & /open
/exit

Provides method/variable/type redefinition and autocompletion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.