jigsaw

Why do we need requires static in java-9 module system? [duplicate]

折月煮酒 提交于 2019-12-01 07:47:53
This question already has an answer here: What's the difference between requires and requires static in module declaration 2 answers Does the Java 9 Module system support optional dependencies? 1 answer I started to learn jigsaw java-9 feature and read some articles/video. I can't understand concept of optional dependencies( requires static ) quote from article : When a module needs to be compiled against types from another module but does not want to depend on it at run time, it can use a requires static clause. If foo requires static bar, the module system behaves different at compile and

How to resolve module-info.java compile error in Jdk9/java-9

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 05:44:50
I am trying to run below code using jdk-9 but facing problem when compile using command Command javac -d mods .\module-info.java com\nirav\modi\Test.java Error .\module-info.java:1: error: class, interface, or enum expected module module1 { } ^ 1 error module-info.java module module1 { } Test.java package com.nirav.modi; class Test { public static void main(String args[]){ System.out.println("Hello Modular..."); } } package structure is like below module1\module-info.java module1\com\nirav\modi\Test.java JDK Version java version "9-ea" Java(TM) SE Runtime Environment (build 9-ea+153) Java

Why is exporting the entire module not allowed?

人走茶凉 提交于 2019-12-01 03:06:55
In Java 9's module declaration there are 2 constructs: exports com.foo; And opens com.foo; Where exports grants compile-time access, while opens allows runtime access, as reflection and resources. opens has one leniency over exports that you can define the whole module as open, resulting the same as explicitly opening every package: open module com.mod { But there's no similar construct exported module com.mod { My Question : Why is it so; what decisions has been made to allow opening the whole module at once but not with exporting? A module's exports define its API, which should be

How to resolve module-info.java compile error in Jdk9/java-9

て烟熏妆下的殇ゞ 提交于 2019-12-01 02:42:15
问题 I am trying to run below code using jdk-9 but facing problem when compile using command Command javac -d mods .\module-info.java com\nirav\modi\Test.java Error .\module-info.java:1: error: class, interface, or enum expected module module1 { } ^ 1 error module-info.java module module1 { } Test.java package com.nirav.modi; class Test { public static void main(String args[]){ System.out.println("Hello Modular..."); } } package structure is like below module1\module-info.java module1\com\nirav

Run spring boot with jdk9 using jigsaw modules

杀马特。学长 韩版系。学妹 提交于 2019-12-01 02:33:36
问题 What's wrong with this application. I thought the mix of classpath jars and module jars are valid. For all jars not having an explicit module-info become an automatic module? When I delete my module-info.java it works. Because IDEA using the classpath for this case. Java(TM) SE Runtime Environment (build 9+176) IntelliJ IDEA 2017.1.4 module-info.java module test { requires spring.boot.autoconfigure; requires spring.boot; } App.java package com.foo.test; import org.springframework.boot

findResource(“”) returning null when module-info.java is present, why is that?

大城市里の小女人 提交于 2019-11-30 10:41:51
I'm debugging why in the presence of module-info.java in my Spring Boot application, spring-orm throws an exception during start up time. This is the exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/UserTransaction at spring.beans@5.0.8.RELEASE/org.springframework.beans.factory.support

Why project Jigsaw / JPMS?

浪尽此生 提交于 2019-11-30 10:12:52
问题 Java's package management system always seemed simple and effective to me. It is heavily used by the JDK itself. We have been using it to mimic the concept of namespaces and modules. What is Project Jigsaw (aka Java Platform Module System) trying to fill in? From the official site: The goal of this Project is to design and implement a standard module system for the Java SE Platform, and to apply that system to the Platform itself and to the JDK. 回答1: Jigsaw and OSGi are trying to solve the

OSGi, Java Modularity and Jigsaw

▼魔方 西西 提交于 2019-11-30 10:10:01
问题 So as of yesterday morning I hadn't a clue as to what OSGi even was. OSGi was just some buzzword that I kept seeing cropping up over and over again, and so I finally set aside some time to brush up on it. It actually seems like pretty cool stuff, so I'd like to start off by stating (for the record) that I'm not anti-OSGi in any respect, nor is this is some "OSGi-bashing" question. At the end of the day, it seems that OSGi has - essentially - addressed JSR 277 on Java Modularity, which

Loading classes and resources in Java 9

回眸只為那壹抹淺笑 提交于 2019-11-30 06:04:46
I was reading this article on InfoQ quoting Reinhold: Developers can still use the Java class path in Java 9 for the Java runtime to search for classes and resource files. It's just that with Java 9's modules, developers no longer need the class path. So now my question is: what is the proper Java 9 way to do the tasks listed above? How do you dynamically load e.g. an image (short of fiddling with relative paths)? Even more interestingly, how would one check if a class is available and make a decision dynamically (e.g. check if Jackson is available and, if so, use it for JSON serialization and

Unable to export a package from java.base module

给你一囗甜甜゛ 提交于 2019-11-30 05:14:46
Using IDEA-EAP for JDK9 development experiments. I am getting the following error - Error:(3, 20) java: package jdk.internal.misc is not visible (package jdk.internal.misc is declared in module java.base, which does not export it to module com.jigsaw.npe) The class definition is as - package experiment; import jdk.internal.misc.Unsafe; public class CompareAndSwap { static Unsafe UNSAFE = Unsafe.getUnsafe(); ... } I've tried including a module-info.java file as well inside the module created using the IDE with the following statements - module com.jigsaw.npe { requires java.base; } Directory