问题
I use OSGI and this is the main reason that I want to disable modules, as I really don't need another module framework. Is it possible to do it, for example using command line option? If yes, then how?
回答1:
There is no option to turn off the module system - it will always be active. This impacts access to JDK-internal APIs, dependencies on Java EE modules, Split packages, and a lot of other small details. Your code and your dependencies have to deal with those migration challenges if you want your application to run on Java 9.
You are by no means forced to create modules, though. You can completely ignore module-info.java
and continue to place all your JARs onto the class path. The module system will silently bundle them all into the unnamed module, which was created for maximum compatibility. You won't even notice the module system is there (assuming you've overcome the challenges I described earlier).
回答2:
Yes surely you can as the interviewee said here
Trisha Gee: Many people don’t realize you can use Java 9 and all its shiny new features WITHOUT using Jigsaw, i.e. you can use Java 9 very happily without migrating any of your code. There are some things which have changed in Java 9 (e.g. hiding away internal APIs) but theoretically, if your application was doing all the right things to begin with, there should be no problem compiling and running with Java 9.
have a look for the entire interview but As you saw we will have two types for Java Applications one for modular world and another for non-module system that's why Red Hat and IBM voted no for JSR 376 as mentioned here but they vote okay after that!
for more about Java 9 Module System with OSGI have a look here
Hope this is useful
来源:https://stackoverflow.com/questions/46061591/is-it-possible-to-disable-modules-in-java-9