java-9

Can't add Java Applications in Eclipse Run Configurations after upgrading to 4.7

*爱你&永不变心* 提交于 2020-01-01 09:27:11
问题 My application isn't running correctly with Java 9. In order to debug it, I upgraded to Eclipse 4.7 (oxygen) since Neon doesn't have Java 9 support, and applied the Java 9 support patch. After doing so, eclipse was failing to load any of my pre-existing Java Applications. Thinking it might be a version difference thing, I deleted them, to try re-adding. But when I click the "New" button to add a configuration, nothing happens. If I double-click "Java Application," I get the following error:

How can I handle split packages in automatic modules?

允我心安 提交于 2020-01-01 09:01:32
问题 I am currently testing to migrate an existing application to Jigsaw Modules. One of my modules uses ElasticSearch along with its Groovy Plugin. org.elasticsearch:elasticsearch org.elasticsearch.module:lang-groovy Unfortunately, they share a split package, so mvn install gives me: x reads package org.elasticsearch.script.groovy from both lang.groovy and elasticsearch once for each required module in the descriptor, where x is the name of each module. I assume that a newer elasticsearch version

Where to place module-info.java using Java 9?

情到浓时终转凉″ 提交于 2020-01-01 08:38:50
问题 I have an OSGI application and I have around 30 bundles (jar files). Today I decided to see how it works/if it works with Java 9. So I started my application and got WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.apache.felix.framework.util.SecureAction (file:/home/.../jar/org.apache.felix.framework-5.4.0.jar) to method java.net.URLClassLoader.addURL(java.net.URL) WARNING: Please consider reporting this to the maintainers of org.apache

Why Java 9 does not simply turn all JARs on the class path into automatic modules?

强颜欢笑 提交于 2020-01-01 00:48:10
问题 In order to understand the categories we have: platform explicit modules application explicit modules open modules automatic modules unnamed module All classes and jars within the classpath will be part of the unnamed module. But why is that what we need? Where is the advantage over automatic modules? I could "require" those damn legacy jars to make them to an automatic module. Do I not have included everything with it? 回答1: There are at least two reasons: Just as regular modules, automatic

Java 9 automatic modules not found

自古美人都是妖i 提交于 2019-12-31 22:24:10
问题 I'm trying to define a Java 9 module. I have defined something like: module my.module.name { } Then many of my files started to give me errors, that they cannot find some packages. Then I used the auto-help feature of IntelliJ and it added to my module-info.java several "requires" statements. So it became something like: module my.module.name { requires spring.web; requires sshd.core; requires com.fasterxml.jackson.core; .... } Now IntelliJ shows all my code without errors. But when I click

Why does \R behave differently in regular expressions between Java 8 and Java 9?

Deadly 提交于 2019-12-31 10:57:05
问题 The following code compiles in both Java 8 & 9, but behaves differently. class Simple { static String sample = "\nEn un lugar\r\nde la Mancha\nde cuyo nombre\r\nno quiero acordarme"; public static void main(String args[]){ String[] chunks = sample.split("\\R\\R"); for (String chunk: chunks) { System.out.println("Chunk : "+chunk); } } } When I run it with Java 8 it returns: Chunk : En un lugar de la Mancha de cuyo nombre no quiero acordarme But when I run it with Java 9 the output is different

Why does \R behave differently in regular expressions between Java 8 and Java 9?

末鹿安然 提交于 2019-12-31 10:57:03
问题 The following code compiles in both Java 8 & 9, but behaves differently. class Simple { static String sample = "\nEn un lugar\r\nde la Mancha\nde cuyo nombre\r\nno quiero acordarme"; public static void main(String args[]){ String[] chunks = sample.split("\\R\\R"); for (String chunk: chunks) { System.out.println("Chunk : "+chunk); } } } When I run it with Java 8 it returns: Chunk : En un lugar de la Mancha de cuyo nombre no quiero acordarme But when I run it with Java 9 the output is different

How to work with resources in Java 9 modules

心不动则不痛 提交于 2019-12-31 02:15:26
问题 I built a small (hello world style) java 9 project using gradle and the jigsaw plugin. For a junit test I tried to access some file as a resource, but classLoader.getResource(filename) is not able to locate the file. Usually you put the file as src/test/resources/foo.txt and access it as /foo.txt , but with Java 9 it looks like things changed and resources are (similar like classes) encapsulated in modules. Where exactly do I have to put the resource file for gradle to package it correctly?

idea: too many module declarations found

不羁的心 提交于 2019-12-30 18:07:06
问题 I want to create hello world java 9 application and start it in intellij idea. Now I have following structure: content of inner module-info.java: module my.module.Second { requires my.module.First; } content of outer module-info.java: module my.module.First { exports my.pack; } But idea complains about my project: Error:(1, 1) java: too many module declarations found I don't understand why it happens and what really wrong. So Question: My question is how to force idea to accept my hello world

Using List.of for immutable list with single element instead of Collections.singletonList

雨燕双飞 提交于 2019-12-30 10:29:36
问题 Java 9 introduce factory methods to create immutable lists with List.of . Which is more suitable to create an immutable list of one element ? List<String> immutableList1 = List.of("one"); List<String> immutableList2 = Collections.singletonList("one"); 回答1: Prefer using factory method List<String> immutableList1 = List.of("one"); Because they disallow null elements is one of the benefit and also factory methods in List interface are handy to add multiple objects and creates immutable List They